Skip to content

Commit 7eb6640

Browse files
authored
Add roles from JWT payload (#71)
* Add roles from jwt payload * Bump @workos-inc/authkit-js to 0.14.0
1 parent 4812e75 commit 7eb6640

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
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

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"react": ">=17"
3838
},
3939
"dependencies": {
40-
"@workos-inc/authkit-js": "0.13.0"
40+
"@workos-inc/authkit-js": "0.14.0"
4141
}
4242
}

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)