Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork225
fix: implement admin permissions#429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:4.0
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
pwa/components/admin/Admin.tsx Outdated
| constAdminWithOIDC=()=>{ | ||
| // Can't use next-auth/middleware because of https://github.com/nextauthjs/next-auth/discussions/7488 | ||
| const{data:session, status}=useSession(); | ||
| const{ permissions}=usePermissions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
usePermissions can only be called by children of react-admin's<Admin> component (otherwise there is no AuthProviderContext and QueryClientContext available). That's why you have an error.
The proper fix would be to call theusePermissions inBookList and other admin-only components, and redirect to a/forbidden CustomRoute if the permissions don't match.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Fixes#427