diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/users.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 4ad0e33da..8fbab4dd0 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -21,6 +21,7 @@ import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | |||
21 | import { Redis } from '../../lib/redis' | 21 | import { Redis } from '../../lib/redis' |
22 | import { UserModel } from '../../models/account/user' | 22 | import { UserModel } from '../../models/account/user' |
23 | import { areValidationErrors } from './utils' | 23 | import { areValidationErrors } from './utils' |
24 | import { ActorModel } from '../../models/activitypub/actor' | ||
24 | 25 | ||
25 | const usersAddValidator = [ | 26 | const usersAddValidator = [ |
26 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), | 27 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), |
@@ -271,6 +272,14 @@ async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email: | |||
271 | return false | 272 | return false |
272 | } | 273 | } |
273 | 274 | ||
275 | const actor = await ActorModel.loadLocalByName(username) | ||
276 | if (actor) { | ||
277 | res.status(409) | ||
278 | .send({ error: 'Another actor (account/channel) with this name already exists.' }) | ||
279 | .end() | ||
280 | return false | ||
281 | } | ||
282 | |||
274 | return true | 283 | return true |
275 | } | 284 | } |
276 | 285 | ||