mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Prevent duplicate usernames from being added
This commit is contained in:
parent
a564a03ee3
commit
79349124bc
1 changed files with 3 additions and 0 deletions
|
|
@ -35,6 +35,9 @@ function buildUserEvent(user: User) {
|
||||||
/** Adds a user to the database. */
|
/** Adds a user to the database. */
|
||||||
async function insertUser(user: User) {
|
async function insertUser(user: User) {
|
||||||
debug('insertUser', JSON.stringify(user));
|
debug('insertUser', JSON.stringify(user));
|
||||||
|
if (await findUser({ username: user.username })) {
|
||||||
|
throw new Error('User already exists');
|
||||||
|
}
|
||||||
const event = await buildUserEvent(user);
|
const event = await buildUserEvent(user);
|
||||||
return pipeline.handleEvent(event);
|
return pipeline.handleEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue