diff options
author | Lucas Declercq <lucas-dclrcq@users.noreply.github.com> | 2018-10-10 08:57:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-10 08:57:00 +0200 |
commit | 9ccff23877ec8d740fcd5a9254fcd2424b62d2c8 (patch) | |
tree | 03a47436ce88a3169aed491439517001ab773bb6 /server/middlewares/validators | |
parent | ee7c25c767c357bd12570889f8ccd79ba9ea4eb9 (diff) | |
download | PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.tar.gz PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.tar.zst PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.zip |
Add explicit error message that changing video ownership only works with local accounts (#1214)
* Add explicit error message that changing video ownership only works with local accounts
* Remove superfluous logger
* Remove unneeded end() to error responses
* Add a message on client side to prevent transfering ownership to a remote account
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index d6b8aa725..1d0a64bb1 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -69,7 +69,6 @@ const videosAddValidator = getCommonVideoAttributes().concat([ | |||
69 | if (isAble === false) { | 69 | if (isAble === false) { |
70 | res.status(403) | 70 | res.status(403) |
71 | .json({ error: 'The user video quota is exceeded with this video.' }) | 71 | .json({ error: 'The user video quota is exceeded with this video.' }) |
72 | .end() | ||
73 | 72 | ||
74 | return cleanUpReqFiles(req) | 73 | return cleanUpReqFiles(req) |
75 | } | 74 | } |
@@ -82,7 +81,6 @@ const videosAddValidator = getCommonVideoAttributes().concat([ | |||
82 | logger.error('Invalid input file in videosAddValidator.', { err }) | 81 | logger.error('Invalid input file in videosAddValidator.', { err }) |
83 | res.status(400) | 82 | res.status(400) |
84 | .json({ error: 'Invalid input file.' }) | 83 | .json({ error: 'Invalid input file.' }) |
85 | .end() | ||
86 | 84 | ||
87 | return cleanUpReqFiles(req) | 85 | return cleanUpReqFiles(req) |
88 | } | 86 | } |
@@ -120,7 +118,6 @@ const videosUpdateValidator = getCommonVideoAttributes().concat([ | |||
120 | cleanUpReqFiles(req) | 118 | cleanUpReqFiles(req) |
121 | return res.status(409) | 119 | return res.status(409) |
122 | .json({ error: 'Cannot set "private" a video that was not private.' }) | 120 | .json({ error: 'Cannot set "private" a video that was not private.' }) |
123 | .end() | ||
124 | } | 121 | } |
125 | 122 | ||
126 | if (req.body.channelId && !await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) | 123 | if (req.body.channelId && !await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) |
@@ -150,7 +147,6 @@ const videosCustomGetValidator = (fetchType: VideoFetchType) => { | |||
150 | if (video.VideoChannel.Account.userId !== user.id && !user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) { | 147 | if (video.VideoChannel.Account.userId !== user.id && !user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) { |
151 | return res.status(403) | 148 | return res.status(403) |
152 | .json({ error: 'Cannot get this private or blacklisted video.' }) | 149 | .json({ error: 'Cannot get this private or blacklisted video.' }) |
153 | .end() | ||
154 | } | 150 | } |
155 | 151 | ||
156 | return next() | 152 | return next() |
@@ -239,8 +235,8 @@ const videosChangeOwnershipValidator = [ | |||
239 | const nextOwner = await AccountModel.loadLocalByName(req.body.username) | 235 | const nextOwner = await AccountModel.loadLocalByName(req.body.username) |
240 | if (!nextOwner) { | 236 | if (!nextOwner) { |
241 | res.status(400) | 237 | res.status(400) |
242 | .type('json') | 238 | .json({ error: 'Changing video ownership to a remote account is not supported yet' }) |
243 | .end() | 239 | |
244 | return | 240 | return |
245 | } | 241 | } |
246 | res.locals.nextOwner = nextOwner | 242 | res.locals.nextOwner = nextOwner |
@@ -271,7 +267,7 @@ const videosTerminateChangeOwnershipValidator = [ | |||
271 | } else { | 267 | } else { |
272 | res.status(403) | 268 | res.status(403) |
273 | .json({ error: 'Ownership already accepted or refused' }) | 269 | .json({ error: 'Ownership already accepted or refused' }) |
274 | .end() | 270 | |
275 | return | 271 | return |
276 | } | 272 | } |
277 | } | 273 | } |
@@ -288,7 +284,7 @@ const videosAcceptChangeOwnershipValidator = [ | |||
288 | if (isAble === false) { | 284 | if (isAble === false) { |
289 | res.status(403) | 285 | res.status(403) |
290 | .json({ error: 'The user video quota is exceeded with this video.' }) | 286 | .json({ error: 'The user video quota is exceeded with this video.' }) |
291 | .end() | 287 | |
292 | return | 288 | return |
293 | } | 289 | } |
294 | 290 | ||
@@ -389,7 +385,6 @@ function areErrorsInScheduleUpdate (req: express.Request, res: express.Response) | |||
389 | if (!req.body.scheduleUpdate.updateAt) { | 385 | if (!req.body.scheduleUpdate.updateAt) { |
390 | res.status(400) | 386 | res.status(400) |
391 | .json({ error: 'Schedule update at is mandatory.' }) | 387 | .json({ error: 'Schedule update at is mandatory.' }) |
392 | .end() | ||
393 | 388 | ||
394 | return true | 389 | return true |
395 | } | 390 | } |