Skip to content

Commit

Permalink
Use await
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed May 7, 2024
1 parent bc6e987 commit dd9470a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions web/backend/src/controllers/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ usersRouter.get('/user_rights', (req, res) => {
});

// This call (only for admins) allows an admin to add a role to a voter.
usersRouter.post('/add_role', (req, res, next) => {
usersRouter.post('/add_role', async (req, res, next) => {
if (!isAuthorized(req.session.userId, PERMISSIONS.SUBJECTS.ROLES, PERMISSIONS.ACTIONS.ADD)) {
res.status(400).send('Unauthorized - only admins allowed');
return;
Expand All @@ -44,7 +44,7 @@ usersRouter.post('/add_role', (req, res, next) => {
if ('userId' in req.body) {
try {
readSCIPER(req.body.userId);
Promise.resolve(addPolicy(req.body.userId, req.body.subject, req.body.permission));
await addPolicy(req.body.userId, req.body.subject, req.body.permission);
} catch (error) {
res.status(400).send(`Error while adding single user to roles: ${error}`);
return;
Expand All @@ -54,7 +54,7 @@ usersRouter.post('/add_role', (req, res, next) => {
} else if ('userIds' in req.body) {
try {
req.body.userIds.every(readSCIPER);
Promise.resolve(addListPolicy(req.body.userIds, req.body.subject, req.body.permission));
await addListPolicy(req.body.userIds, req.body.subject, req.body.permission);
} catch (error) {
res.status(400).send(`Error while adding multiple users to roles: ${error}`);
return;
Expand Down

0 comments on commit dd9470a

Please sign in to comment.