-async function registerUser (req: express.Request, res: express.Response) {
- const body: UserRegister = req.body
-
- const userToCreate = buildUser({
- ...pick(body, [ 'username', 'password', 'email' ]),
-
- emailVerified: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION ? false : null
- })
-
- const { user, account, videoChannel } = await createUserAccountAndChannelAndPlaylist({
- userToCreate: userToCreate,
- userDisplayName: body.displayName || undefined,
- channelNames: body.channel
- })
-
- auditLogger.create(body.username, new UserAuditView(user.toFormattedJSON()))
- logger.info('User %s with its channel and account registered.', body.username)
-
- if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) {
- await sendVerifyUserEmail(user)
- }
-
- Notifier.Instance.notifyOnNewUserRegistration(user)
-
- Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel, req, res })
-
- return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
-}
-