react-admin
react-admin copied to clipboard
disableAuthentication prop on (Infinite)List is ignored when used on a Dashboard
What you were expecting: I want to have a root page, that's a List, to not require authentication.
What happened instead: Page redirects to login.
- React-admin version: 4.15.0
- React version: 18.2.0
Please follow the issue template (including a repro)
Here you go
https://stackblitz.com/edit/github-nmv8yb
I see you have put disableAuthentication
only on the mobile version of the List, but not on the desktop version. Is it intended?
Yeah sorry. Didn't see. I edited the template
Thanks. You are correct, the dashboard
route is protected by default, and this cannot be disabled via a prop.
However, when on the dashboard, react-admin will call checkAuth(params)
with params = { route: 'dashboard' }
.
So you can add the following line to your authProvider to disable the check for the dashboard route only:
checkAuth: (params) => {
+ if (params?.route === 'dashboard') return Promise.resolve();
return localStorage.getItem('not_authenticated')
? Promise.reject()
: Promise.resolve();
},
AFAICT this is not documented anywhere, so I'll leave this issue open as a doc issue.
Thanks for the report!