diff options
author | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-04-18 22:02:32 +0300 |
---|---|---|
committer | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-04-18 22:02:32 +0300 |
commit | 3061c24780a2dcf46dc4960d50c3636cab6b918f (patch) | |
tree | 2a48ace270e84b3c639b9ae1966c4a2d42d5eaa2 | |
parent | Merge branch 'master' of https://github.com/fosscord/fosscord-server (diff) | |
download | server-3061c24780a2dcf46dc4960d50c3636cab6b918f.tar.xz |
general rights enforcement stuff
-rw-r--r-- | api/src/util/handlers/route.ts | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/api/src/util/handlers/route.ts b/api/src/util/handlers/route.ts index 0048c4dd..3d3bbc37 100644 --- a/api/src/util/handlers/route.ts +++ b/api/src/util/handlers/route.ts @@ -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); } |