- Notifications
You must be signed in to change notification settings - Fork928
feat: Add update user password endpoint#1310
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
I realized/remember the UI should be able to update the password for other users as well so I think we should skip the password verification when the user is admin and if it is trying to change another user's password. Or, to make it simple for BETA, I can just remove this verification or comment the block. Thoughts? |
codecovbot commentedMay 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #1310 +/- ##==========================================+ Coverage 66.10% 66.18% +0.07%========================================== Files 281 281 Lines 18424 18479 +55 Branches 220 220 ==========================================+ Hits 12180 12230 +50- Misses 4982 4984 +2- Partials 1262 1265 +3
Continue to review full report at Codecov.
|
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.
Do we not have an RBAC gate for admins yet? Kinda worried about shipping this and allow any user to reset any other user's password.
Uh oh!
There was an error while loading.Please reload this page.
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.
Just a few nits, other than that I think the PR looks good. 👍🏻
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
… bq/update-user-password
@f0ssel RBAC added! |
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.
The frontend bit looks good to me!
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.
Small suggestions but it looks good 👍
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@@ -287,6 +287,41 @@ func TestUpdateUserProfile(t *testing.T) { | |||
}) | |||
} | |||
func TestUpdateUserPassword(t *testing.T) { |
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.
Let's also add some tests to make sure the rbac is working here, I'd like to ensure that the user itself cannot perform this action, and neither can other non-admin users.
BrunoQuaresmaMay 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
So from what I'm understanding we want to test:
- A non-admin user can't update any password
- An admin can update another user's password
Is that?
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.
Updated!
Co-authored-by: Garrett Delfosse <garrett@coder.com>
@@ -76,14 +76,6 @@ func ExtractUserParam(db database.Store) func(http.Handler) http.Handler { | |||
} | |||
} | |||
apiKey := APIKey(r) | |||
if apiKey.UserID != user.ID { |
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.
I removed this because it was "overriding" RBAC roles. I know we don’t have the RBAC in place for all the user routes, but I can try to do that next. Probably I can send a PR on Monday. Thoughts? cc.:@f0ssel
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.
Discussion on Slack:https://codercom.slack.com/archives/CJURPL8DN/p1651843502606399
Closes#1309