diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-14 17:31:26 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad (patch) | |
tree | f4191f3c04a5230fcf8ca3d6ca3248643fc4151d /server/middlewares/validators/account.ts | |
parent | e34c85e527100c0b5c44567bd951e95be41b8d7e (diff) | |
download | PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.tar.gz PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.tar.zst PeerTube-350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad.zip |
Follow works
Diffstat (limited to 'server/middlewares/validators/account.ts')
-rw-r--r-- | server/middlewares/validators/account.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts index 3ccf2ea21..58eeed3cc 100644 --- a/server/middlewares/validators/account.ts +++ b/server/middlewares/validators/account.ts | |||
@@ -8,13 +8,13 @@ import { | |||
8 | isUserVideoQuotaValid, | 8 | isUserVideoQuotaValid, |
9 | logger | 9 | logger |
10 | } from '../../helpers' | 10 | } from '../../helpers' |
11 | import { isAccountNameWithHostValid } from '../../helpers/custom-validators/video-accounts' | 11 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' |
12 | import { database as db } from '../../initializers/database' | 12 | import { database as db } from '../../initializers/database' |
13 | import { AccountInstance } from '../../models' | 13 | import { AccountInstance } from '../../models' |
14 | import { checkErrors } from './utils' | 14 | import { checkErrors } from './utils' |
15 | 15 | ||
16 | const localAccountValidator = [ | 16 | const localAccountValidator = [ |
17 | param('nameWithHost').custom(isAccountNameWithHostValid).withMessage('Should have a valid account with domain name (myuser@domain.tld)'), | 17 | param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), |
18 | 18 | ||
19 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 19 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
20 | logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) | 20 | logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) |
@@ -33,10 +33,8 @@ export { | |||
33 | 33 | ||
34 | // --------------------------------------------------------------------------- | 34 | // --------------------------------------------------------------------------- |
35 | 35 | ||
36 | function checkLocalAccountExists (nameWithHost: string, res: express.Response, callback: (err: Error, account: AccountInstance) => void) { | 36 | function checkLocalAccountExists (name: string, res: express.Response, callback: (err: Error, account: AccountInstance) => void) { |
37 | const [ name, host ] = nameWithHost.split('@') | 37 | db.Account.loadLocalByName(name) |
38 | |||
39 | db.Account.loadLocalAccountByNameAndPod(name, host) | ||
40 | .then(account => { | 38 | .then(account => { |
41 | if (!account) { | 39 | if (!account) { |
42 | return res.status(404) | 40 | return res.status(404) |