fixed broken /check endpoint

This commit is contained in:
mrjvs 2018-10-13 14:37:19 +02:00
parent c73bba5a64
commit 1205b62d24
2 changed files with 3 additions and 5 deletions

View File

@ -13,8 +13,7 @@ function adminAuthenticationRequired(req, res, next) {
if (req.isAuthenticated() && req.user.role && req.user.role === 'admin') {
return next();
} else {
console.log('sending auth error');
common.sendApiAuthError(req, res);
common.sendApiAuthError(res);
}
}

View File

@ -101,10 +101,9 @@ router.post('/admin/api/v1/register', adminUserMiddleware.adminAuthenticationReq
* }
*/
router.get('/admin/api/v1/check', adminUserMiddleware.authenticationOptional, (req, res) => {
if (!req.user) req.user = {};
common.sendApiReturn(res, {
IsAuthed: req.isAuthenticated(),
role: req.user.role ? req.user.role : undefined
isAuthed: req.user ? true : false,
role: req.user ? (req.user.role ? req.user.role : undefined) : undefined
});
});