aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/oauth2.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-01 16:03:53 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-01 16:03:53 +0200
commit69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (patch)
tree8659f819818a3da6419959b6b7838a7f0557c948 /server/middlewares/oauth2.js
parenta3ee6fa22dee4b68fcde9cd23708b471db446e11 (diff)
downloadPeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.gz
PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.tar.zst
PeerTube-69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd.zip
OAuth/User models refractoring -> use mongoose api
Diffstat (limited to 'server/middlewares/oauth2.js')
-rw-r--r--server/middlewares/oauth2.js35
1 files changed, 0 insertions, 35 deletions
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 @@
1'use strict'
2
3const OAuthServer = require('express-oauth-server')
4
5const logger = require('../helpers/logger')
6
7const oAuthServer = new OAuthServer({
8 model: require('../models/users')
9})
10
11const oAuth2 = {
12 authenticate: authenticate,
13 token: token
14}
15
16function authenticate (req, res, next) {
17 oAuthServer.authenticate()(req, res, function (err) {
18 if (err) {
19 logger.error('Cannot authenticate.', { error: err })
20 return res.sendStatus(500)
21 }
22
23 if (res.statusCode === 401 || res.statusCode === 400) return res.end()
24
25 return next()
26 })
27}
28
29function token (req, res, next) {
30 return oAuthServer.token()(req, res, next)
31}
32
33// ---------------------------------------------------------------------------
34
35module.exports = oAuth2