Skip to content

Commit

Permalink
Overwrite activeRole cookie when it's not contained in allowed role…
Browse files Browse the repository at this point in the history
…s list (#1131)

overwrite `activeRole` cookie when it's not contained in allowed roles
  • Loading branch information
skovati authored Feb 26, 2024
1 parent e1ffda3 commit 22900e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const handleSSOAuth: Handle = async ({ event, resolve }) => {
event.cookies.set('user', userCookie, cookieOpts);
}

// don't overwrite existing activeRole
if (!activeRoleCookie || activeRoleCookie === 'deleted') {
// don't overwrite existing activeRole, unless it doesn't exist anymore
if (!activeRoleCookie || activeRoleCookie === 'deleted' || !roles.allowedRoles.includes(activeRoleCookie)) {
event.cookies.set('activeRole', roles.defaultRole, cookieOpts);
}
}
Expand Down

0 comments on commit 22900e6

Please sign in to comment.