-
Notifications
You must be signed in to change notification settings - Fork 253
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
users: change user role #1506
users: change user role #1506
Conversation
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.
A few high-level things we could
Co-authored-by: Nathaniel Caza <[email protected]>
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.
Edit: Fixed in latest commit
I got this error when trying to update a user other than myself to admin, in the UI console:

The network tab showed this response on the request:
{
"errors": [
{
"message": "Cannot query field \"setUserRole\" on type \"Mutation\".",
"locations": [{ "line": 2, "column": 3 }],
"extensions": { "code": "GRAPHQL_VALIDATION_FAILED" }
},
{
"message": "Unknown type \"SetUserRoleInput\".",
"locations": [{ "line": 1, "column": 1 }],
"extensions": { "code": "GRAPHQL_VALIDATION_FAILED" }
}
],
"data": null
}
Co-authored-by: Nathaniel Cook <[email protected]>
make check
to catch common errors. Fixed any that came up.Description:
This PR provides the ability for admins to change user roles.
Which issue(s) this PR fixes:
Part of #1247
Describe any introduced user-facing changes:
Admins will be able to see 'Edit' icon on the user details page.
After that, there will be an option to check/uncheck the admin role option.
Checking it will set the user as admin, unchecking will set the role to user.
If the logged-in user is already an admin, unchecking the checkbox will show a warning notice mentioning the change in role and it's effects.
Describe any introduced API changes:
A split logic has been applied to the
updateUser
mutation.Whenever the
role
field is specified, the logic will go to a different store method that updates the user role, else it will go to the store update a user logic.This decision was made since even though there is currently no UI for updateUser fields like name, email, etc that might change in the future (and is possible today via the graphql playground) editing user fields like name, email, etc could be done by the user themselves. But in the case of changing user's role, this operation is strictly limited to admins only. No non-admin user should be allowed to make themselves as an admin. So, in order to keep the two different permission checks separate for updating user fields and changing user role, the logic is split up accordingly.