Prevent duplicate usernames from being added

This commit is contained in:
Alex Gleason 2023-12-30 09:57:33 -06:00
parent a564a03ee3
commit 79349124bc
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 3 additions and 0 deletions

View File

@ -35,6 +35,9 @@ function buildUserEvent(user: User) {
/** Adds a user to the database. */
async function insertUser(user: User) {
debug('insertUser', JSON.stringify(user));
if (await findUser({ username: user.username })) {
throw new Error('User already exists');
}
const event = await buildUserEvent(user);
return pipeline.handleEvent(event);
}