diff options
Diffstat (limited to 'server/middlewares/validators/account.ts')
-rw-r--r-- | server/middlewares/validators/account.ts | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts deleted file mode 100644 index 551f67d61..000000000 --- a/server/middlewares/validators/account.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { param } from 'express-validator' | ||
3 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' | ||
4 | import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared' | ||
5 | |||
6 | const localAccountValidator = [ | ||
7 | param('name') | ||
8 | .custom(isAccountNameValid), | ||
9 | |||
10 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
11 | if (areValidationErrors(req, res)) return | ||
12 | if (!await doesLocalAccountNameExist(req.params.name, res)) return | ||
13 | |||
14 | return next() | ||
15 | } | ||
16 | ] | ||
17 | |||
18 | const accountNameWithHostGetValidator = [ | ||
19 | param('accountName') | ||
20 | .exists(), | ||
21 | |||
22 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
23 | if (areValidationErrors(req, res)) return | ||
24 | if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return | ||
25 | |||
26 | return next() | ||
27 | } | ||
28 | ] | ||
29 | |||
30 | // --------------------------------------------------------------------------- | ||
31 | |||
32 | export { | ||
33 | localAccountValidator, | ||
34 | accountNameWithHostGetValidator | ||
35 | } | ||