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 | c3f69bc6d835035bc03b80896348477ba94fa473 (patch) | |
tree | 701530a53978eda612e476d61b1930d200875e99 /api/src | |
parent | Merge branch 'master' of https://github.com/fosscord/fosscord-server (diff) | |
download | server-c3f69bc6d835035bc03b80896348477ba94fa473.tar.xz |
general rights enforcement stuff
Diffstat (limited to 'api/src')
-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); } |