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