Skip to content

Commit

Permalink
Update coderabbitai's review
Browse files Browse the repository at this point in the history
  • Loading branch information
gusah009 committed Jul 20, 2024
1 parent 98dc7c5 commit cc3c18b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions server/backend/database/memory/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,12 @@ func (d *DB) DeleteUserInfoByName(_ context.Context, username string) error {
defer txn.Abort()

raw, err := txn.First(tblUsers, "username", username)
if err != nil || raw == nil {
if err != nil {
return fmt.Errorf("find user by username: %w", err)
}
if raw == nil {
return fmt.Errorf("%s: %w", username, database.ErrUserNotFound)
}

info := raw.(*database.UserInfo).DeepCopy()
if err = txn.Delete(tblUsers, info); err != nil {
Expand All @@ -652,9 +655,12 @@ func (d *DB) ChangePassword(_ context.Context, username, hashedNewPassword strin
defer txn.Abort()

raw, err := txn.First(tblUsers, "username", username)
if err != nil || raw == nil {
if err != nil {
return fmt.Errorf("find user by username: %w", err)
}
if raw == nil {
return fmt.Errorf("%s: %w", username, database.ErrUserNotFound)
}

info := raw.(*database.UserInfo).DeepCopy()
info.HashedPassword = hashedNewPassword
Expand Down
2 changes: 1 addition & 1 deletion server/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func DeleteAccountByName(
return nil
}

// ChangePassword deletes a user by name.
// ChangePassword changes the password for a user.
func ChangePassword(
ctx context.Context,
be *backend.Backend,
Expand Down

0 comments on commit cc3c18b

Please sign in to comment.