Fortunately, each time the dataProvider returns an error, react-admin calls the authProvider.checkError() method. If it returns a rejected promise, react-admin calls the authProvider.logout() method immediately, and asks the user to log in again....
现在我们的服务器就拥有了身份认证的功能,访问除了’/login’外的其它接口时,服务端会根据请求的header中access-token来判断请求是否有效,如果无效则会返回401状态码。 当客户端收到401的状态码时,需要跳转到登录页面进行登录,有效的管理员账号为admin,密码为123456。 以POST方法提交下面的参数到’http://localhost:80...
React-admin supports both authentication and authorization, allowing you to secure your admin app with your preferred authentication strategy. Since there are many strategies (OAuth, MFA, passwordless, magic link, etc.), react-admin delegates this logic to an authProvider....
const {account, password} = req.body; if (account === 'admin' && password === '123456') { res.header('access-token', Date.now()); res.json(true); } else { res.json(false); } }); server.use(require('./auth')); server.use(router); server.listen(3000, function () { cons...
react admin在CRUD操作时返回未授权的401错误 、、 我正在做一个react-admin项目。后端是使用Django rest框架编写的,该框架运行在docker容器上。我已经为react admin编写了自己的authProvider.js和dataProvider.js。但是,每当我执行创建、编辑和删除操作时,我都会自动注销,并显示401未授权错误。://localhost:8000...
</AuthRouter> </HashRouter> </ConfigProvider> ) } export default App react-admin布局模板 整个项目内置了3种布局样式(分栏/垂直布局/水平布局)。 布局模板在layouts目录下的template文件夹。 /** * Layout布局模板 * @author YXY */ import { useMemo } from 'react' ...
当client收到401的状态码时,须要跳转到登录页面进行登录,有效的管理员账号为admin。密码为123456。 以POST方法提交下面的參数到’http://localhost:3000/login‘接口。就能够完毕登录。 {"account":"admin","password":"123456"} 登录成功后,接口返回true,而且在返回的headers中包括了一个有效的access-token,用于在...
export const withAdminAuth = (Comp) => { return class extends React.Component { constructor(props) { super(props) this.state = { isAdmin: true, } } componentDidMount() { // 从后端获取用户的权限 const currentRole = 'Admin' this.setState({ ...
const dataProvider = drfProvider('http://127.0.0.1:8000/api/token-auth/', httpClient); const App = () => ( <Admin title="" loginPage={Login} catchAll={NotFound} logoutButton={PfsLogoutButton} authProvider={authProvider} dataProvider={dataProvider} ...
import { Provider } from 'react-redux'; import Admin from '@v/Admin' import Login from '@v/Login'; import './assets/style/base.less' function App() { return ( <Router> <Switch> <Route path='/' exact component={Admin}></Route> ...