Making permissions work in authorize page

This commit is contained in:
Fabian Stamm 2018-11-10 15:34:10 +01:00
parent 0633311ba1
commit 6580cbf667
1 changed files with 3 additions and 2 deletions

View File

@ -54,16 +54,17 @@ ViewRouter.get("/auth", Stacker(GetUserMiddleware(false, true), async (req, res)
let proms: PromiseLike<void>[] = [];
if (scope) {
for (let perm of scope.split(";")) {
proms.push(Permission.findOne({ id: Number(perm) }).then(p => {
proms.push(Permission.findById(perm).then(p => {
if (!p) return Promise.reject(new Error());
permissions.push(p);
}));
}
}
let err = false;
await Promise.all(proms).catch(err => {
await Promise.all(proms).catch(e => {
err = true;
})
Logging.debug(err);
if (err) {
return sendError("invalid_scope")
}