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:
parent
5f183fdf65
commit
3061c24780
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user