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

View File

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