mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
24 lines
426 B
JavaScript
24 lines
426 B
JavaScript
import {
|
|
NotAuthorized,
|
|
} from '../libs/errors';
|
|
|
|
export function ensureAdmin (req, res, next) {
|
|
let user = res.locals.user;
|
|
|
|
if (!user.contributor.admin) {
|
|
return next(new NotAuthorized(res.t('noAdminAccess')));
|
|
}
|
|
|
|
next();
|
|
}
|
|
|
|
export function ensureSudo (req, res, next) {
|
|
let user = res.locals.user;
|
|
|
|
if (!user.contributor.sudo) {
|
|
return next(new NotAuthorized(res.t('noSudoAccess')));
|
|
}
|
|
|
|
next();
|
|
}
|