aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/account.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/account.ts')
-rw-r--r--server/middlewares/validators/account.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 5abe942d6..3ccf2ea21 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,21 +1,20 @@
1import { param } from 'express-validator/check'
2import * as express from 'express' 1import * as express from 'express'
3 2import { param } from 'express-validator/check'
4import { database as db } from '../../initializers/database'
5import { checkErrors } from './utils'
6import { 3import {
7 logger,
8 isUserUsernameValid,
9 isUserPasswordValid,
10 isUserVideoQuotaValid,
11 isUserDisplayNSFWValid, 4 isUserDisplayNSFWValid,
5 isUserPasswordValid,
12 isUserRoleValid, 6 isUserRoleValid,
13 isAccountNameValid 7 isUserUsernameValid,
8 isUserVideoQuotaValid,
9 logger
14} from '../../helpers' 10} from '../../helpers'
11import { isAccountNameWithHostValid } from '../../helpers/custom-validators/video-accounts'
12import { database as db } from '../../initializers/database'
15import { AccountInstance } from '../../models' 13import { AccountInstance } from '../../models'
14import { checkErrors } from './utils'
16 15
17const localAccountValidator = [ 16const localAccountValidator = [
18 param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), 17 param('nameWithHost').custom(isAccountNameWithHostValid).withMessage('Should have a valid account with domain name (myuser@domain.tld)'),
19 18
20 (req: express.Request, res: express.Response, next: express.NextFunction) => { 19 (req: express.Request, res: express.Response, next: express.NextFunction) => {
21 logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) 20 logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
@@ -34,8 +33,10 @@ export {
34 33
35// --------------------------------------------------------------------------- 34// ---------------------------------------------------------------------------
36 35
37function checkLocalAccountExists (name: string, res: express.Response, callback: (err: Error, account: AccountInstance) => void) { 36function checkLocalAccountExists (nameWithHost: string, res: express.Response, callback: (err: Error, account: AccountInstance) => void) {
38 db.Account.loadLocalAccountByName(name) 37 const [ name, host ] = nameWithHost.split('@')
38
39 db.Account.loadLocalAccountByNameAndPod(name, host)
39 .then(account => { 40 .then(account => {
40 if (!account) { 41 if (!account) {
41 return res.status(404) 42 return res.status(404)