Skip to content

Commit

Permalink
wrap role updates in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
skovati committed Feb 16, 2024
1 parent 3215f4b commit 1fd435c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/packages/auth/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ export async function upsertUserRoles(username: string, default_role: string, al
}

export async function syncRolesToDB(username: string, default_role: string, allowed_roles: string[]) {
const db = DbMerlin.getDb();

await db.query('begin;');
await deleteUserAllowedRoles(username);
await upsertUserRoles(username, default_role, allowed_roles);
await db.query('commit;');
}

export function decodeJwt(authorizationHeader: string | undefined): JwtDecode {
Expand Down

0 comments on commit 1fd435c

Please sign in to comment.