Implementing User Roles
Hello, I am trying to implement roles of USER, MODERATOR, or ADMIN
I find the admin and organization plugins a bit intimidating
but more importantly I am not sure if they are the exact use case for my roles
here is my current code
Is this a good approach? I have the default role as USER
Or should I be using the admin or organization plugins and adjusting them to fit my above requirements?
2 Replies
you can actually do that but you can get more benefit and customization with less bloat - with accessControls - like you can define your ac's and roles like this - `
and pass it admin plugin here
and now you can check for a permission like this -
check on client
check on server
Oh this is good stuff thank you for this really helped me better understand the admin plugin in general too
Does the list of adminUserIds override the actual role of the user in the database?
@KiNFiSH are you able to help, i made a simpler approach
but when i log in with a user who has user.session.role === 'user'
this fails
bump
I believe the reason is I did not pass headers in the function
So if I want to check if the currently logged in user has permission
I can do either one of the following right?
pass the headers
OR
Pass the userId if I called getSession earlier in the code?