diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-10 14:48:08 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 38fa2065831b5f55be0d7f30f19a62c967397208 (patch) | |
tree | 4a986465e3a88c85bc6a8b5fc992e0f2edd63ef0 /server/middlewares/validators/video-channels.ts | |
parent | 0d0e8dd0904b380b70e19ebcb4763d65601c4632 (diff) | |
download | PeerTube-38fa2065831b5f55be0d7f30f19a62c967397208.tar.gz PeerTube-38fa2065831b5f55be0d7f30f19a62c967397208.tar.zst PeerTube-38fa2065831b5f55be0d7f30f19a62c967397208.zip |
Remove references to author
Diffstat (limited to 'server/middlewares/validators/video-channels.ts')
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 7d611728b..53416a857 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts | |||
@@ -9,19 +9,19 @@ import { | |||
9 | isVideoChannelDescriptionValid, | 9 | isVideoChannelDescriptionValid, |
10 | isVideoChannelNameValid, | 10 | isVideoChannelNameValid, |
11 | checkVideoChannelExists, | 11 | checkVideoChannelExists, |
12 | checkVideoAuthorExists | 12 | checkVideoAccountExists |
13 | } from '../../helpers' | 13 | } from '../../helpers' |
14 | import { UserInstance } from '../../models' | 14 | import { UserInstance } from '../../models' |
15 | import { UserRight } from '../../../shared' | 15 | import { UserRight } from '../../../shared' |
16 | 16 | ||
17 | const listVideoAuthorChannelsValidator = [ | 17 | const listVideoAccountChannelsValidator = [ |
18 | param('authorId').custom(isIdOrUUIDValid).withMessage('Should have a valid author id'), | 18 | param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'), |
19 | 19 | ||
20 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 20 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
21 | logger.debug('Checking listVideoAuthorChannelsValidator parameters', { parameters: req.body }) | 21 | logger.debug('Checking listVideoAccountChannelsValidator parameters', { parameters: req.body }) |
22 | 22 | ||
23 | checkErrors(req, res, () => { | 23 | checkErrors(req, res, () => { |
24 | checkVideoAuthorExists(req.params.authorId, res, next) | 24 | checkVideoAccountExists(req.params.accountId, res, next) |
25 | }) | 25 | }) |
26 | } | 26 | } |
27 | ] | 27 | ] |
@@ -54,7 +54,7 @@ const videoChannelsUpdateValidator = [ | |||
54 | .end() | 54 | .end() |
55 | } | 55 | } |
56 | 56 | ||
57 | if (res.locals.videoChannel.Author.userId !== res.locals.oauth.token.User.id) { | 57 | if (res.locals.videoChannel.Account.userId !== res.locals.oauth.token.User.id) { |
58 | return res.status(403) | 58 | return res.status(403) |
59 | .json({ error: 'Cannot update video channel of another user' }) | 59 | .json({ error: 'Cannot update video channel of another user' }) |
60 | .end() | 60 | .end() |
@@ -98,7 +98,7 @@ const videoChannelGetValidator = [ | |||
98 | // --------------------------------------------------------------------------- | 98 | // --------------------------------------------------------------------------- |
99 | 99 | ||
100 | export { | 100 | export { |
101 | listVideoAuthorChannelsValidator, | 101 | listVideoAccountChannelsValidator, |
102 | videoChannelsAddValidator, | 102 | videoChannelsAddValidator, |
103 | videoChannelsUpdateValidator, | 103 | videoChannelsUpdateValidator, |
104 | videoChannelsRemoveValidator, | 104 | videoChannelsRemoveValidator, |
@@ -119,8 +119,8 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () => | |||
119 | 119 | ||
120 | // Check if the user can delete the video channel | 120 | // Check if the user can delete the video channel |
121 | // The user can delete it if s/he is an admin | 121 | // The user can delete it if s/he is an admin |
122 | // Or if s/he is the video channel's author | 122 | // Or if s/he is the video channel's account |
123 | if (user.hasRight(UserRight.REMOVE_ANY_VIDEO_CHANNEL) === false && res.locals.videoChannel.Author.userId !== user.id) { | 123 | if (user.hasRight(UserRight.REMOVE_ANY_VIDEO_CHANNEL) === false && res.locals.videoChannel.Account.userId !== user.id) { |
124 | return res.status(403) | 124 | return res.status(403) |
125 | .json({ error: 'Cannot remove video channel of another user' }) | 125 | .json({ error: 'Cannot remove video channel of another user' }) |
126 | .end() | 126 | .end() |
@@ -131,7 +131,7 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () => | |||
131 | } | 131 | } |
132 | 132 | ||
133 | function checkVideoChannelIsNotTheLastOne (res: express.Response, callback: () => void) { | 133 | function checkVideoChannelIsNotTheLastOne (res: express.Response, callback: () => void) { |
134 | db.VideoChannel.countByAuthor(res.locals.oauth.token.User.Author.id) | 134 | db.VideoChannel.countByAccount(res.locals.oauth.token.User.Account.id) |
135 | .then(count => { | 135 | .then(count => { |
136 | if (count <= 1) { | 136 | if (count <= 1) { |
137 | return res.status(409) | 137 | return res.status(409) |