]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/account.ts
Add hover effect on login/create an account button
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / account.ts
CommitLineData
e4f97bab 1import * as express from 'express'
7a7724e6 2import { param } from 'express-validator/check'
3fd3ab2d 3import { isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
da854ddd 4import { logger } from '../../helpers/logger'
a2431b7d 5import { areValidationErrors } from './utils'
e4f97bab
C
6
7const localAccountValidator = [
350e31d6 8 param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
e4f97bab 9
a2431b7d 10 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
e4f97bab
C
11 logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
12
a2431b7d
C
13 if (areValidationErrors(req, res)) return
14 if (!await isLocalAccountNameExist(req.params.name, res)) return
15
16 return next()
e4f97bab
C
17 }
18]
19
20// ---------------------------------------------------------------------------
21
22export {
23 localAccountValidator
24}