1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

general rights enforcement stuff

This commit is contained in:
Erkin Alp Güney 2022-04-18 22:02:32 +03:00
parent 5f183fdf65
commit 3061c24780

View File

@ -6,6 +6,7 @@ import {
FieldErrors,
FosscordApiErrors,
getPermission,
getRights,
PermissionResolvable,
Permissions,
RightResolvable,
@ -105,6 +106,8 @@ export function route(opts: RouteOptions) {
if (opts.right) {
const required = new Rights(opts.right);
req.rights = await getRights(req.user_id);
if (!req.rights || !req.rights.has(required)) {
throw FosscordApiErrors.MISSING_RIGHTS.withParams(opts.right as string);
}