在管理组件中,我想要一个仪表板,如下所示:
<Admin dashboard={Dashboard}>
<Resource name="list" list={MyList} />
</Admin>
从react-admin文档中的Authentication page:
By default,an react-admin app doesn’t require authentication. But if
the REST API ever returns a 401 (Unauthorized) or a 403 (Forbidden)
response,then the user is redirected to the /login route. You have
nothing to do – it’s already built in.
认证由authProvider属性配置.
<Admin dashboard={Dashboard} authProvider={authProvider}>
<Resource name="list" list={MyList} />
</Admin>
每次用户导航时都会调用auth提供程序.
因此,您可以实现authProvider来检查用户是否已登录或进入登录页面.
从Authentication page – Checking Credentials During Navigation:
Redirecting to the login page whenever a REST response uses a 401
status code is usually not enough,because react-admin keeps data on
the client side,and Could display stale data while contacting the
server – even after the credentials are no longer valid.Fortunately,each time the user navigates,react-admin calls the
authProvider with the AUTH_CHECK type,so it’s the ideal place to
check for credentials.
原文地址:https://www.jb51.cc/js/531172.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。