feat(auth): lab7 upgrade legacy Argon2id hashes after successful login

This commit is contained in:
Голиков Maximillian Антон
2026-11-29 12:09:24 +03:00
parent 1e785e3107
commit 4fe1d17e50
6 changed files with 67 additions and 0 deletions
@@ -57,3 +57,17 @@ func (r *UserRepo) GetByUsername(ctx context.Context, username string) (*domain.
}
return nil, &domain.NotFoundError{Entity: "user", ID: username}
}
func (r *UserRepo) ReplacePasswordHash(ctx context.Context, id, previous, next string) (bool, error) {
if err := ctx.Err(); err != nil {
return false, err
}
r.mu.Lock()
defer r.mu.Unlock()
u := r.users[id]
if u == nil || u.PasswordHash != previous {
return false, nil
}
u.PasswordHash = next
return true, nil
}