fix(striker-ui-api): don't consider name of deleted users as used

main
Tsu-ba-me 2 years ago
parent e93c48bec4
commit a9d0ae4ae7
  1. 6
      striker-ui-api/src/lib/request_handlers/user/createUser.ts

@ -1,7 +1,7 @@
import assert from 'assert';
import { RequestHandler } from 'express';
import { REP_PEACEFUL_STRING, REP_UUID } from '../../consts';
import { DELETED, REP_PEACEFUL_STRING, REP_UUID } from '../../consts';
import { insertOrUpdateUser, query } from '../../accessModule';
import { sanitize } from '../../sanitize';
@ -33,7 +33,9 @@ export const createUser: RequestHandler<
);
const [[userCount]]: [[number]] = await query(
`SELECT COUNT(user_uuid) FROM users WHERE user_name = '${userName}';`,
`SELECT COUNT(user_uuid)
FROM users
WHERE user_algorithm != '${DELETED}' AND user_name = '${userName}';`,
);
assert(userCount === 0, `User name [${userName}] already used`);

Loading…
Cancel
Save