diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-22 14:03:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-22 14:03:50 +0200 |
commit | 2c2befaacaa7063df0d4557b71c187ee168a8eb6 (patch) | |
tree | ed31dba97ff754d6d20f32bf7eec10e580afa121 /server/middlewares/validators/shared | |
parent | ff9d43f62a4f4737c5bfe955883b48c5440f323a (diff) | |
download | PeerTube-2c2befaacaa7063df0d4557b71c187ee168a8eb6.tar.gz PeerTube-2c2befaacaa7063df0d4557b71c187ee168a8eb6.tar.zst PeerTube-2c2befaacaa7063df0d4557b71c187ee168a8eb6.zip |
Fix video right check
Diffstat (limited to 'server/middlewares/validators/shared')
-rw-r--r-- | server/middlewares/validators/shared/videos.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts index 39aab6df7..2c2ae3811 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts | |||
@@ -2,7 +2,7 @@ import { Request, Response } from 'express' | |||
2 | import { isUUIDValid } from '@server/helpers/custom-validators/misc' | 2 | import { isUUIDValid } from '@server/helpers/custom-validators/misc' |
3 | import { loadVideo, VideoLoadType } from '@server/lib/model-loaders' | 3 | import { loadVideo, VideoLoadType } from '@server/lib/model-loaders' |
4 | import { isAbleToUploadVideo } from '@server/lib/user' | 4 | import { isAbleToUploadVideo } from '@server/lib/user' |
5 | import { authenticatePromiseIfNeeded } from '@server/middlewares/auth' | 5 | import { authenticatePromise } from '@server/middlewares/auth' |
6 | import { VideoModel } from '@server/models/video/video' | 6 | import { VideoModel } from '@server/models/video/video' |
7 | import { VideoChannelModel } from '@server/models/video/video-channel' | 7 | import { VideoChannelModel } from '@server/models/video/video-channel' |
8 | import { VideoFileModel } from '@server/models/video/video-file' | 8 | import { VideoFileModel } from '@server/models/video/video-file' |
@@ -137,7 +137,7 @@ async function checkCanSeeAuthVideo (req: Request, res: Response, video: MVideoI | |||
137 | return false | 137 | return false |
138 | } | 138 | } |
139 | 139 | ||
140 | await authenticatePromiseIfNeeded(req, res, authenticateInQuery) | 140 | await authenticatePromise(req, res, authenticateInQuery) |
141 | 141 | ||
142 | const user = res.locals.oauth?.token.User | 142 | const user = res.locals.oauth?.token.User |
143 | if (!user) return fail() | 143 | if (!user) return fail() |
@@ -154,14 +154,15 @@ async function checkCanSeeAuthVideo (req: Request, res: Response, video: MVideoI | |||
154 | } | 154 | } |
155 | 155 | ||
156 | const isOwnedByUser = videoWithRights.VideoChannel.Account.userId === user.id | 156 | const isOwnedByUser = videoWithRights.VideoChannel.Account.userId === user.id |
157 | if (privacy === VideoPrivacy.PRIVATE || privacy === VideoPrivacy.UNLISTED) { | 157 | |
158 | if (isOwnedByUser && user.hasRight(UserRight.SEE_ALL_VIDEOS)) return true | 158 | if (videoWithRights.isBlacklisted()) { |
159 | if (isOwnedByUser || user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) return true | ||
159 | 160 | ||
160 | return fail() | 161 | return fail() |
161 | } | 162 | } |
162 | 163 | ||
163 | if (videoWithRights.isBlacklisted()) { | 164 | if (privacy === VideoPrivacy.PRIVATE || privacy === VideoPrivacy.UNLISTED) { |
164 | if (isOwnedByUser || user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) return true | 165 | if (isOwnedByUser || user.hasRight(UserRight.SEE_ALL_VIDEOS)) return true |
165 | 166 | ||
166 | return fail() | 167 | return fail() |
167 | } | 168 | } |