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
View File
@@ -243,6 +243,13 @@ export function fakeApi(initial: FakeUser[]) {
if (!user || user.role === 'user') return problem(403, 'auth.forbidden');
const target = users.get(userPath[1]!);
if (!target) return problem(404, 'common.not_found');
if (typeof body?.username === 'string') {
if (user.role !== 'admin') return problem(403, 'auth.forbidden');
const username = body.username.trim().toLowerCase();
if ([...users.values()].some((u) => u.id !== target.id && u.username.toLowerCase() === username))
return problem(422, 'auth.username_taken', { errors: [{ field: 'username', code: 'auth.username_taken' }] });
target.username = username;
}
if (typeof body?.reviews_uploads === 'boolean') {
if (user.role !== 'admin') return problem(403, 'auth.forbidden');
target.reviews_uploads = body.reviews_uploads;