Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: implement admin permissions #429

Draft
wants to merge 3 commits into
base: 4.0
Choose a base branch
from
Draft

Conversation

vincentchalamon
Copy link
Contributor

@vincentchalamon vincentchalamon commented Jul 12, 2024

Fixes #427

@@ -116,6 +117,7 @@ const AdminWithContext = ({ session }: { session: Session }) => {
const AdminWithOIDC = () => {
// Can't use next-auth/middleware because of https://github.com/nextauthjs/next-auth/discussions/7488
const { data: session, status } = useSession();
const { permissions } = usePermissions();
Copy link
Contributor

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 the usePermissions in BookList and other admin-only components, and redirect to a /forbidden CustomRoute if the permissions don't match.

@vincentchalamon vincentchalamon changed the base branch from main to 3.3 September 15, 2024 18:06
@vincentchalamon vincentchalamon changed the base branch from 3.3 to 4.0 September 19, 2024 09:41
@vincentchalamon vincentchalamon marked this pull request as ready for review October 1, 2024 13:01
@vincentchalamon vincentchalamon marked this pull request as draft October 1, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin authentication problems
2 participants