Navigation Menu

Skip to content

Commit

Permalink
Remove user's access tokens on password change
Browse files Browse the repository at this point in the history
  • Loading branch information
darh committed Nov 10, 2021
1 parent a385fe1 commit 0157719
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions system/service/auth.go
Expand Up @@ -607,6 +607,10 @@ func (svc auth) ChangePassword(ctx context.Context, userID uint64, oldPassword,
return err
}

if err = svc.RemoveAccessTokens(ctx, u); err != nil {
return err
}

return nil
}()

Expand Down
10 changes: 7 additions & 3 deletions system/service/user.go
Expand Up @@ -697,7 +697,7 @@ func (svc user) SetPassword(ctx context.Context, userID uint64, newPassword stri
a = UserActionSetPassword
)

err = func() error {
err = func() (err error) {
if u, err = store.LookupUserByID(ctx, svc.store, userID); err != nil {
return err
}
Expand All @@ -712,6 +712,10 @@ func (svc user) SetPassword(ctx context.Context, userID uint64, newPassword stri
return UserErrNotAllowedToUpdate()
}

if err = svc.auth.RemoveAccessTokens(ctx, u); err != nil {
return
}

if newPassword == "" {
a = UserActionRemovePassword
return svc.auth.RemovePasswordCredentials(ctx, userID)
Expand All @@ -721,8 +725,8 @@ func (svc user) SetPassword(ctx context.Context, userID uint64, newPassword stri
return UserErrPasswordNotSecure()
}

if err := svc.auth.SetPasswordCredentials(ctx, userID, newPassword); err != nil {
return err
if err = svc.auth.SetPasswordCredentials(ctx, userID, newPassword); err != nil {
return
}

return nil
Expand Down

0 comments on commit 0157719

Please sign in to comment.