diff options
Diffstat (limited to 'server/controllers/api/videos/token.ts')
-rw-r--r-- | server/controllers/api/videos/token.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/server/controllers/api/videos/token.ts b/server/controllers/api/videos/token.ts deleted file mode 100644 index e961ffd9e..000000000 --- a/server/controllers/api/videos/token.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { VideoTokensManager } from '@server/lib/video-tokens-manager' | ||
3 | import { VideoPrivacy, VideoToken } from '@shared/models' | ||
4 | import { asyncMiddleware, optionalAuthenticate, videoFileTokenValidator, videosCustomGetValidator } from '../../../middlewares' | ||
5 | |||
6 | const tokenRouter = express.Router() | ||
7 | |||
8 | tokenRouter.post('/:id/token', | ||
9 | optionalAuthenticate, | ||
10 | asyncMiddleware(videosCustomGetValidator('only-video')), | ||
11 | videoFileTokenValidator, | ||
12 | generateToken | ||
13 | ) | ||
14 | |||
15 | // --------------------------------------------------------------------------- | ||
16 | |||
17 | export { | ||
18 | tokenRouter | ||
19 | } | ||
20 | |||
21 | // --------------------------------------------------------------------------- | ||
22 | |||
23 | function generateToken (req: express.Request, res: express.Response) { | ||
24 | const video = res.locals.onlyVideo | ||
25 | |||
26 | const files = video.privacy === VideoPrivacy.PASSWORD_PROTECTED | ||
27 | ? VideoTokensManager.Instance.createForPasswordProtectedVideo({ videoUUID: video.uuid }) | ||
28 | : VideoTokensManager.Instance.createForAuthUser({ videoUUID: video.uuid, user: res.locals.oauth.token.User }) | ||
29 | |||
30 | return res.json({ | ||
31 | files | ||
32 | } as VideoToken) | ||
33 | } | ||