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

feat: Prevent role changing on yourself. #1931

Merged
merged 3 commits into from
May 31, 2022
Merged

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented May 31, 2022

Only allow changing roles on other users. Not much value in self changing
at the moment

#1847

Future Work

Update UI error

Screenshot from 2022-05-31 15-15-55

Response payload

{"message":"You cannot change your own roles."}

Only allow changing roles on other users. Not much value in self changing
at the moment
@Emyrk Emyrk requested a review from f0ssel May 31, 2022 20:16
@@ -445,7 +445,7 @@ func TestGrantRoles(t *testing.T) {
require.Error(t, err, "member cannot change other's roles")
requireStatusCode(t, err, http.StatusForbidden)

_, err = member.UpdateUserRoles(ctx, memberUser.ID.String(), codersdk.UpdateRoles{
_, err = member.UpdateUserRoles(ctx, first.UserID.String(), codersdk.UpdateRoles{
Roles: []string{rbac.RoleMember()},
})
require.Error(t, err, "member cannot change any roles")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should reference "changing their own role" in the error or test name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added those tests 👍

@Emyrk Emyrk merged commit 7acb742 into main May 31, 2022
@Emyrk Emyrk deleted the stevenmasley/admin_demote branch May 31, 2022 20:50
kylecarbs pushed a commit that referenced this pull request Jun 10, 2022
* feat: Prevent role changing on yourself.

Only allow changing roles on other users. Not much value in self changing
at the moment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants