1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-01-05 15:58:03 -05:00

Change requireAuth to only export itself

This commit is contained in:
Jack Foltz 2018-07-27 14:08:02 -04:00
parent f97070452b
commit 094a45b6be
Signed by: foltik
GPG Key ID: 303F88F996E95541
3 changed files with 6 additions and 4 deletions

View File

@ -9,7 +9,7 @@ const Invite = require(ModelPath + 'Invite.js');
const passport = require('passport');
const canonicalizeRequest = require('../util/canonicalize').canonicalizeRequest;
const requireAuth = require('../util/requireAuth').requireAuth;
const requireAuth = require('../util/requireAuth');
const wrap = require('../util/wrap.js');
// Wraps passport.authenticate to return a promise

View File

@ -11,7 +11,7 @@ const multer = require('multer');
const fileUpload = multer({dest: config.get('Upload.path')}).single('file');
const fsPromises = require('fs').promises;
const requireAuth = require('../util/requireAuth').requireAuth;
const requireAuth = require('../util/requireAuth');
const wrap = require('../util/wrap.js');
const generatedIdExists = async id =>

View File

@ -8,7 +8,7 @@ const verifyScope = (scope, requiredScope) => scope.indexOf(requiredScope) !== -
// If the request is authenticated and has the desired scope, continue.
// If the request is authenticated, but lacks the required scope, return 403 Forbidden.
// If the request is unauthenticated, return 401 Unauthorized.
exports.requireAuth = scope =>
const requireAuth = scope =>
wrap(async (req, res, next) => {
if (req.isAuthenticated()) {
if (scope ? verifyScope(req.session.passport.scope, scope) : true) {
@ -34,4 +34,6 @@ exports.requireAuth = scope =>
} else {
res.status(401).json({'message': 'Unauthorized.'});
}
});
});
module.exports = requireAuth;