From 69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 1 Jul 2016 16:03:53 +0200 Subject: OAuth/User models refractoring -> use mongoose api --- server/middlewares/oauth2.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 server/middlewares/oauth2.js (limited to 'server/middlewares/oauth2.js') diff --git a/server/middlewares/oauth2.js b/server/middlewares/oauth2.js deleted file mode 100644 index 1defdc02e..000000000 --- a/server/middlewares/oauth2.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' - -const OAuthServer = require('express-oauth-server') - -const logger = require('../helpers/logger') - -const oAuthServer = new OAuthServer({ - model: require('../models/users') -}) - -const oAuth2 = { - authenticate: authenticate, - token: token -} - -function authenticate (req, res, next) { - oAuthServer.authenticate()(req, res, function (err) { - if (err) { - logger.error('Cannot authenticate.', { error: err }) - return res.sendStatus(500) - } - - if (res.statusCode === 401 || res.statusCode === 400) return res.end() - - return next() - }) -} - -function token (req, res, next) { - return oAuthServer.token()(req, res, next) -} - -// --------------------------------------------------------------------------- - -module.exports = oAuth2 -- cgit v1.2.3