Skip to content

Commit

Permalink
fix(): validate realm_access claim existence in token
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseGoncalves committed Nov 2, 2023
1 parent 759af37 commit 2f6a1ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const setToken = (token: string): void => {
state.token = token
const content = jwtDecode<TokenContent>(state.token)
state.decodedToken = content
state.roles = content.realm_access.roles
state.roles = content.realm_access ? content.realm_access.roles : []
state.username = content.preferred_username
state.resourceRoles = content.resource_access
? Object.fromEntries(Object.entries(content.resource_access).map(([key, value]) => [key, value.roles]))
Expand Down

0 comments on commit 2f6a1ba

Please sign in to comment.