Skip to content

Commit f07c35d

Browse files
committed
Add roles from jwt payload
1 parent 4812e75 commit f07c35d

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules
22
/dist
3+
.idea

src/provider.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) {
4343
} = response;
4444
const {
4545
role = null,
46+
roles = null,
4647
permissions = [],
4748
feature_flags: featureFlags = [],
4849
} = getClaims(accessToken);
@@ -52,6 +53,7 @@ export function AuthKitProvider(props: AuthKitProviderProps) {
5253
user,
5354
organizationId,
5455
role,
56+
roles,
5557
permissions,
5658
featureFlags,
5759
impersonator,
@@ -117,6 +119,7 @@ function isEquivalentWorkOSSession(
117119
a.user?.updatedAt === b.user?.updatedAt &&
118120
a.organizationId === b.organizationId &&
119121
a.role === b.role &&
122+
a.roles === b.roles &&
120123
a.permissions.length === b.permissions.length &&
121124
a.permissions.every((perm, i) => perm === b.permissions[i]) &&
122125
a.featureFlags.length === b.featureFlags.length &&

src/state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface State {
99
isLoading: boolean;
1010
user: User | null;
1111
role: string | null;
12+
roles: string[] | null;
1213
organizationId: string | null;
1314
permissions: string[];
1415
featureFlags: string[];
@@ -19,6 +20,7 @@ export const initialState: State = {
1920
isLoading: true,
2021
user: null,
2122
role: null,
23+
roles: null,
2224
organizationId: null,
2325
permissions: [],
2426
featureFlags: [],

0 commit comments

Comments
 (0)