You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My project has scoped permissioning model. There are multiple contexts and users have specific permissions assigned within the scope of a context. Here's a sample result one could get by calling auth provider's getPermissions() method:
In React Admin, permissions are loaded once, on the page load. This behavior generally makes sense since permissions don't change most of the time.
However, in my use case admins can create new companies (a.k.a scopes) in which permissions need to be recalculated for the application permissioning to work correctly in the newly created context.
Proposed solution
Extend the usePermissions hook to give the ability to refetch permissions when necessary.
const{ refetch }=usePermissions();
Alternatives
To get the expected behavior, I had to implement my own permission management outside of React Admin.
It works well but I thought that this seems like a pretty small change that could save me some code and is generic enough to be useful to the others.
I would be willing to create a pull request with such change but I would like to get your feedback not to waste my time doing work that will not get accepted. Please let me know what you think. :)
Thank you for your suggestion.
This is something that can be done in user-land, by using the queryClient to invalidate the ['auth', 'getPermissions'] queries, which will trigger a refetch.
However, I agree the implementation is almost for free, so I'll accept the PR 🙂
Thanks
Problem
My project has scoped permissioning model. There are multiple contexts and users have specific permissions assigned within the scope of a context. Here's a sample result one could get by calling auth provider's
getPermissions()
method:In React Admin, permissions are loaded once, on the page load. This behavior generally makes sense since permissions don't change most of the time.
However, in my use case admins can create new companies (a.k.a scopes) in which permissions need to be recalculated for the application permissioning to work correctly in the newly created context.
Proposed solution
Extend the
usePermissions
hook to give the ability to refetch permissions when necessary.Alternatives
To get the expected behavior, I had to implement my own permission management outside of React Admin.
It works well but I thought that this seems like a pretty small change that could save me some code and is generic enough to be useful to the others.
I would be willing to create a pull request with such change but I would like to get your feedback not to waste my time doing work that will not get accepted. Please let me know what you think. :)
Update
The implementation seems to be trivial. Here's a PR: #8955
It also seems to be in line with what has been implemented in the
useGetIdentity()
hook:https://marmelab.com/react-admin/useGetIdentity.html#refreshing-the-identity
The text was updated successfully, but these errors were encountered: