diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-01 16:03:53 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-01 16:03:53 +0200 |
commit | 69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (patch) | |
tree | 8659f819818a3da6419959b6b7838a7f0557c948 /server/controllers/api/v1 | |
parent | a3ee6fa22dee4b68fcde9cd23708b471db446e11 (diff) | |
download | PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.gz PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.zst PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.zip |
OAuth/User models refractoring -> use mongoose api
Diffstat (limited to 'server/controllers/api/v1')
-rw-r--r-- | server/controllers/api/v1/pods.js | 6 | ||||
-rw-r--r-- | server/controllers/api/v1/users.js | 9 | ||||
-rw-r--r-- | server/controllers/api/v1/videos.js | 6 |
3 files changed, 11 insertions, 10 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index feb6bd958..9ce8120b2 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -7,7 +7,7 @@ const mongoose = require('mongoose') | |||
7 | const logger = require('../../../helpers/logger') | 7 | const logger = require('../../../helpers/logger') |
8 | const friends = require('../../../lib/friends') | 8 | const friends = require('../../../lib/friends') |
9 | const middlewares = require('../../../middlewares') | 9 | const middlewares = require('../../../middlewares') |
10 | const oAuth2 = middlewares.oauth2 | 10 | const oAuth = middlewares.oauth |
11 | const reqValidator = middlewares.reqValidators.pods | 11 | const reqValidator = middlewares.reqValidators.pods |
12 | const signatureValidator = middlewares.reqValidators.remote.signature | 12 | const signatureValidator = middlewares.reqValidators.remote.signature |
13 | 13 | ||
@@ -17,8 +17,8 @@ const Video = mongoose.model('Video') | |||
17 | 17 | ||
18 | router.get('/', listPodsUrl) | 18 | router.get('/', listPodsUrl) |
19 | router.post('/', reqValidator.podsAdd, addPods) | 19 | router.post('/', reqValidator.podsAdd, addPods) |
20 | router.get('/makefriends', oAuth2.authenticate, reqValidator.makeFriends, makeFriends) | 20 | router.get('/makefriends', oAuth.authenticate, reqValidator.makeFriends, makeFriends) |
21 | router.get('/quitfriends', oAuth2.authenticate, quitFriends) | 21 | router.get('/quitfriends', oAuth.authenticate, quitFriends) |
22 | // Post because this is a secured request | 22 | // Post because this is a secured request |
23 | router.post('/remove', signatureValidator, removePods) | 23 | router.post('/remove', signatureValidator, removePods) |
24 | 24 | ||
diff --git a/server/controllers/api/v1/users.js b/server/controllers/api/v1/users.js index 7ce0b9c6a..caa979567 100644 --- a/server/controllers/api/v1/users.js +++ b/server/controllers/api/v1/users.js | |||
@@ -1,15 +1,16 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | 3 | const config = require('config') |
4 | const mongoose = require('mongoose') | ||
4 | const express = require('express') | 5 | const express = require('express') |
5 | const oAuth2 = require('../../../middlewares').oauth2 | 6 | const oAuth = require('../../../middlewares').oauth |
6 | 7 | ||
7 | const Users = require('../../../models/users') | 8 | const Client = mongoose.model('OAuthClient') |
8 | 9 | ||
9 | const router = express.Router() | 10 | const router = express.Router() |
10 | 11 | ||
11 | router.get('/client', getAngularClient) | 12 | router.get('/client', getAngularClient) |
12 | router.post('/token', oAuth2.token, success) | 13 | router.post('/token', oAuth.token, success) |
13 | 14 | ||
14 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
15 | 16 | ||
@@ -27,7 +28,7 @@ function getAngularClient (req, res, next) { | |||
27 | 28 | ||
28 | if (req.get('host') !== headerHostShouldBe) return res.type('json').status(403).end() | 29 | if (req.get('host') !== headerHostShouldBe) return res.type('json').status(403).end() |
29 | 30 | ||
30 | Users.getFirstClient(function (err, client) { | 31 | Client.loadFirstClient(function (err, client) { |
31 | if (err) return next(err) | 32 | if (err) return next(err) |
32 | if (!client) return next(new Error('No client available.')) | 33 | if (!client) return next(new Error('No client available.')) |
33 | 34 | ||
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index d06ec8d08..ab115bc30 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -9,7 +9,7 @@ const multer = require('multer') | |||
9 | const logger = require('../../../helpers/logger') | 9 | const logger = require('../../../helpers/logger') |
10 | const friends = require('../../../lib/friends') | 10 | const friends = require('../../../lib/friends') |
11 | const middlewares = require('../../../middlewares') | 11 | const middlewares = require('../../../middlewares') |
12 | const oAuth2 = middlewares.oauth2 | 12 | const oAuth = middlewares.oauth |
13 | const pagination = middlewares.pagination | 13 | const pagination = middlewares.pagination |
14 | const reqValidator = middlewares.reqValidators | 14 | const reqValidator = middlewares.reqValidators |
15 | const reqValidatorPagination = reqValidator.pagination | 15 | const reqValidatorPagination = reqValidator.pagination |
@@ -51,7 +51,7 @@ router.get('/', | |||
51 | listVideos | 51 | listVideos |
52 | ) | 52 | ) |
53 | router.post('/', | 53 | router.post('/', |
54 | oAuth2.authenticate, | 54 | oAuth.authenticate, |
55 | reqFiles, | 55 | reqFiles, |
56 | reqValidatorVideos.videosAdd, | 56 | reqValidatorVideos.videosAdd, |
57 | addVideo | 57 | addVideo |
@@ -61,7 +61,7 @@ router.get('/:id', | |||
61 | getVideo | 61 | getVideo |
62 | ) | 62 | ) |
63 | router.delete('/:id', | 63 | router.delete('/:id', |
64 | oAuth2.authenticate, | 64 | oAuth.authenticate, |
65 | reqValidatorVideos.videosRemove, | 65 | reqValidatorVideos.videosRemove, |
66 | removeVideo | 66 | removeVideo |
67 | ) | 67 | ) |