Skip to content

fix: implement admin permissions#429

Closed
vincentchalamon wants to merge 3 commits into4.3from
fix/admin-permissions
Closed

fix: implement admin permissions#429
vincentchalamon wants to merge 3 commits into4.3from
fix/admin-permissions

Conversation

@vincentchalamon
Copy link
Copy Markdown
Contributor

@vincentchalamon vincentchalamon commented Jul 12, 2024

Fixes #427

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
Copy Markdown
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
@vincentchalamon vincentchalamon changed the base branch from 4.0 to 4.3 March 16, 2026 16:10
@vincentchalamon
Copy link
Copy Markdown
Contributor Author

Closing as solved in #614

@vincentchalamon vincentchalamon deleted the fix/admin-permissions branch March 27, 2026 18:08
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