Skip to content

Commit

Permalink
fix: tenantId in new auth with Auth0 (#2569)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 21, 2024
1 parent d94dabd commit 132237b
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 132237b

Please sign in to comment.