diff options
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r-- | server/middlewares/validators/users.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 38f8aed5b..71e529872 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -5,7 +5,7 @@ import * as validator from 'validator' | |||
5 | 5 | ||
6 | import { database as db } from '../../initializers/database' | 6 | import { database as db } from '../../initializers/database' |
7 | import { checkErrors } from './utils' | 7 | import { checkErrors } from './utils' |
8 | import { logger } from '../../helpers' | 8 | import { isSignupAllowed, logger } from '../../helpers' |
9 | import { VideoInstance } from '../../models' | 9 | import { VideoInstance } from '../../models' |
10 | 10 | ||
11 | function usersAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 11 | function usersAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
@@ -88,11 +88,22 @@ function usersVideoRatingValidator (req: express.Request, res: express.Response, | |||
88 | }) | 88 | }) |
89 | } | 89 | } |
90 | 90 | ||
91 | function ensureUserRegistrationAllowed (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
92 | isSignupAllowed().then(allowed => { | ||
93 | if (allowed === false) { | ||
94 | return res.status(403).send('User registration is not enabled or user limit is reached.') | ||
95 | } | ||
96 | |||
97 | return next() | ||
98 | }) | ||
99 | } | ||
100 | |||
91 | // --------------------------------------------------------------------------- | 101 | // --------------------------------------------------------------------------- |
92 | 102 | ||
93 | export { | 103 | export { |
94 | usersAddValidator, | 104 | usersAddValidator, |
95 | usersRemoveValidator, | 105 | usersRemoveValidator, |
96 | usersUpdateValidator, | 106 | usersUpdateValidator, |
97 | usersVideoRatingValidator | 107 | usersVideoRatingValidator, |
108 | ensureUserRegistrationAllowed | ||
98 | } | 109 | } |