From b3b926474204ad736ec434aafc8afc6bc55079f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 13 May 2016 16:31:14 +0200 Subject: Authenticate before make/quit friends (server + tests) --- server/controllers/api/v1/pods.js | 13 +++++++------ server/controllers/api/v1/remoteVideos.js | 6 +++--- server/controllers/api/v1/users.js | 2 +- server/controllers/api/v1/videos.js | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index fd13034a2..cec51f272 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js @@ -4,11 +4,12 @@ const express = require('express') const logger = require('../../../helpers/logger') const friends = require('../../../lib/friends') -const middleware = require('../../../middlewares') +const middlewares = require('../../../middlewares') const Pods = require('../../../models/pods') -const reqValidator = middleware.reqValidators.pods -const secureMiddleware = middleware.secure -const secureRequest = middleware.reqValidators.remote.secureRequest +const oAuth2 = middlewares.oauth2 +const reqValidator = middlewares.reqValidators.pods +const secureMiddleware = middlewares.secure +const secureRequest = middlewares.reqValidators.remote.secureRequest const videos = require('../../../lib/videos') const Videos = require('../../../models/videos') @@ -16,8 +17,8 @@ const router = express.Router() router.get('/', listPods) router.post('/', reqValidator.podsAdd, addPods) -router.get('/makefriends', reqValidator.makeFriends, makeFriends) -router.get('/quitfriends', quitFriends) +router.get('/makefriends', oAuth2.authenticate, reqValidator.makeFriends, makeFriends) +router.get('/quitfriends', oAuth2.authenticate, quitFriends) // Post because this is a secured request router.post('/remove', secureRequest, secureMiddleware.decryptBody, removePods) diff --git a/server/controllers/api/v1/remoteVideos.js b/server/controllers/api/v1/remoteVideos.js index cc4bc41e2..2f41c0411 100644 --- a/server/controllers/api/v1/remoteVideos.js +++ b/server/controllers/api/v1/remoteVideos.js @@ -3,9 +3,9 @@ const express = require('express') const map = require('lodash/map') -const middleware = require('../../../middlewares') -const secureMiddleware = middleware.secure -const reqValidator = middleware.reqValidators.remote +const middlewares = require('../../../middlewares') +const secureMiddleware = middlewares.secure +const reqValidator = middlewares.reqValidators.remote const logger = require('../../../helpers/logger') const Videos = require('../../../models/videos') const videos = require('../../../lib/videos') diff --git a/server/controllers/api/v1/users.js b/server/controllers/api/v1/users.js index 54ff0d743..7ce0b9c6a 100644 --- a/server/controllers/api/v1/users.js +++ b/server/controllers/api/v1/users.js @@ -2,7 +2,7 @@ const config = require('config') const express = require('express') -const oAuth2 = require('../../../middlewares/oauth2') +const oAuth2 = require('../../../middlewares').oauth2 const Users = require('../../../models/users') diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index 9891bf4c6..b6e3de08f 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js @@ -9,9 +9,9 @@ const multer = require('multer') const constants = require('../../../initializers/constants') const logger = require('../../../helpers/logger') const friends = require('../../../lib/friends') -const middleware = require('../../../middlewares') -const oAuth2 = require('../../../middlewares/oauth2') -const reqValidator = middleware.reqValidators.videos +const middlewares = require('../../../middlewares') +const oAuth2 = middlewares.oauth2 +const reqValidator = middlewares.reqValidators.videos const utils = require('../../../helpers/utils') const Videos = require('../../../models/videos') // model const videos = require('../../../lib/videos') -- cgit v1.2.3