aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/account.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-27 14:44:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:53 +0100
commit4e50b6a1c9a3eb261e04ede73241648e6edf21d6 (patch)
treee1c6c121d561ffc1cf2996daec03a1e7f27f0a25 /server/middlewares/validators/account.ts
parent74bb2cb8348d6794ed3a0e2ec94c8c9abdde82cf (diff)
downloadPeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.gz
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.zst
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.zip
Add shares forward and collection on videos/video channels
Diffstat (limited to 'server/middlewares/validators/account.ts')
-rw-r--r--server/middlewares/validators/account.ts26
1 files changed, 2 insertions, 24 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 07ae76b63..47ed6a7bb 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,9 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator/check'
3import { logger } from '../../helpers' 3import { logger } from '../../helpers'
4import { isAccountNameValid } from '../../helpers/custom-validators/accounts' 4import { checkLocalAccountNameExists, isAccountNameValid } from '../../helpers/custom-validators/accounts'
5import { database as db } from '../../initializers/database'
6import { AccountInstance } from '../../models'
7import { checkErrors } from './utils' 5import { checkErrors } from './utils'
8 6
9const localAccountValidator = [ 7const localAccountValidator = [
@@ -13,7 +11,7 @@ const localAccountValidator = [
13 logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) 11 logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
14 12
15 checkErrors(req, res, () => { 13 checkErrors(req, res, () => {
16 checkLocalAccountExists(req.params.name, res, next) 14 checkLocalAccountNameExists(req.params.name, res, next)
17 }) 15 })
18 } 16 }
19] 17]
@@ -23,23 +21,3 @@ const localAccountValidator = [
23export { 21export {
24 localAccountValidator 22 localAccountValidator
25} 23}
26
27// ---------------------------------------------------------------------------
28
29function checkLocalAccountExists (name: string, res: express.Response, callback: (err: Error, account: AccountInstance) => void) {
30 db.Account.loadLocalByName(name)
31 .then(account => {
32 if (!account) {
33 return res.status(404)
34 .send({ error: 'Account not found' })
35 .end()
36 }
37
38 res.locals.account = account
39 return callback(null, account)
40 })
41 .catch(err => {
42 logger.error('Error in account request validator.', err)
43 return res.sendStatus(500)
44 })
45}