mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-28 13:55:37 +00:00
24 lines
436 B
JavaScript
24 lines
436 B
JavaScript
|
|
import {
|
||
|
|
NotAuthorized,
|
||
|
|
} from '../../libs/api-v3/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();
|
||
|
|
}
|