UNPKG

@greenpress/auth

Version:

Express Passport authentication service

18 lines (17 loc) 592 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onlyPrivileged = exports.onlyAuthenticated = void 0; exports.onlyAuthenticated = function onlyAuthenticated(req, res, next) { if (!req.userPayload) { res.status(401).json({ message: 'you are not authorized' }).end(); return; } next(); }; exports.onlyPrivileged = function onlyPrivileged(req, res, next) { if (!(req.userPayload && req.userPayload.isPrivileged)) { res.status(401).json({ message: 'you are not authorized' }).end(); return; } next(); };