mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 01:29:21 +00:00
23 lines
426 B
JavaScript
23 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();
|
|
}
|