fix(auth): allow admins to change any username including their own
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m6s
ci / ts / ts (packages + web) (push) Successful in 2m59s
ci / api / api (push) Successful in 49s
ci / db / db (push) Successful in 1m17s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m25s

This commit is contained in:
mrleo1nid committed 2026-10-21 17:33:19 +03:00
1 parent b0cbd0f149
commit c34272d508
16 files changed
+431 -266

No files matched your search

+7 -2
View File
@@ -340,8 +340,9 @@ func (s *PgStore) UpdateUser(ctx context.Context, id uuid.UUID, upd UserUpdate)
r := string(*upd.Role)
role = &r
}
return scanUser(s.q.QueryRow(ctx, `
u, err := scanUser(s.q.QueryRow(ctx, `
UPDATE users SET
username = COALESCE($8, username),
display_name = CASE WHEN $2 THEN $3 ELSE display_name END,
role = COALESCE($4::user_role, role),
is_blocked = COALESCE($5, is_blocked),
@@ -349,7 +350,11 @@ func (s *PgStore) UpdateUser(ctx context.Context, id uuid.UUID, upd UserUpdate)
token_version = token_version + CASE WHEN $6 THEN 1 ELSE 0 END,
updated_at = now()
WHERE id = $1
RETURNING `+userColumns, id, setName, name, role, upd.IsBlocked, upd.RevokeTokens, upd.ReviewsUploads))
RETURNING `+userColumns, id, setName, name, role, upd.IsBlocked, upd.RevokeTokens, upd.ReviewsUploads, upd.Username))
if isUniqueViolation(err) {
return User{}, ErrUsernameTaken
}
return u, err
}
// ResetPassword реализует Store.