Skip to content

Commit

Permalink
Merge branch 'main' into Matvey-Kuk/v-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Matvey-Kuk authored Nov 21, 2024
2 parents 4f133e4 + 132237b commit 13f05c2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions keep-ui/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,20 @@ const config = {
}
return true;
},
jwt: async ({ token, user, account }): Promise<JWT> => {
jwt: async ({ token, user, account, profile }): Promise<JWT> => {
if (account && user) {
let accessToken: string | undefined;
let tenantId: string | undefined = user.tenantId;
let role: string | undefined = user.role;
// Ensure we always have an accessToken
if (authType == AuthType.AUTH0) {
accessToken = account.id_token;
if ((profile as any)?.keep_tenant_id) {
tenantId = (profile as any).keep_tenant_id;
}
if ((profile as any)?.keep_role) {
role = (profile as any).keep_role;
}
} else {
accessToken =
user.accessToken || account.access_token || account.id_token;
Expand All @@ -212,8 +220,8 @@ const config = {
}

token.accessToken = accessToken;
token.tenantId = user.tenantId;
token.role = user.role;
token.tenantId = tenantId;
token.role = role;

if (authType === AuthType.KEYCLOAK) {
token.refreshToken = account.refresh_token;
Expand Down

0 comments on commit 13f05c2

Please sign in to comment.