general rights enforcement stuff
This commit is contained in:
parent
e7461aba3c
commit
c3f69bc6d8
@ -6,6 +6,7 @@ import {
|
|||||||
FieldErrors,
|
FieldErrors,
|
||||||
FosscordApiErrors,
|
FosscordApiErrors,
|
||||||
getPermission,
|
getPermission,
|
||||||
|
getRights,
|
||||||
PermissionResolvable,
|
PermissionResolvable,
|
||||||
Permissions,
|
Permissions,
|
||||||
RightResolvable,
|
RightResolvable,
|
||||||
@ -105,6 +106,8 @@ export function route(opts: RouteOptions) {
|
|||||||
|
|
||||||
if (opts.right) {
|
if (opts.right) {
|
||||||
const required = new Rights(opts.right);
|
const required = new Rights(opts.right);
|
||||||
|
req.rights = await getRights(req.user_id);
|
||||||
|
|
||||||
if (!req.rights || !req.rights.has(required)) {
|
if (!req.rights || !req.rights.has(required)) {
|
||||||
throw FosscordApiErrors.MISSING_RIGHTS.withParams(opts.right as string);
|
throw FosscordApiErrors.MISSING_RIGHTS.withParams(opts.right as string);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user