]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/account.ts
Implement signup approval in server
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / account.ts
index 88c57eaa1adb072830b612714b00ffebde2d3c0b..551f67d61fb68dc8d0a506b9cdddfe275dca7ef9 100644 (file)
@@ -1,30 +1,27 @@
-import * as express from 'express'
-import { param } from 'express-validator/check'
-import { isAccountNameValid, isAccountNameWithHostExist, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
-import { logger } from '../../helpers/logger'
-import { areValidationErrors } from './utils'
+import express from 'express'
+import { param } from 'express-validator'
+import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
+import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
 
 const localAccountValidator = [
-  param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
+  param('name')
+    .custom(isAccountNameValid),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
-
     if (areValidationErrors(req, res)) return
-    if (!await isLocalAccountNameExist(req.params.name, res)) return
+    if (!await doesLocalAccountNameExist(req.params.name, res)) return
 
     return next()
   }
 ]
 
 const accountNameWithHostGetValidator = [
-  param('accountName').exists().withMessage('Should have an account name with host'),
+  param('accountName')
+    .exists(),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
-
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
+    if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
 
     return next()
   }