Skip to content

Commit 03e9a62

Browse files
fix(trackSession): adapt two modes of 'embed' and 'redirect'
1 parent 506bd29 commit 03e9a62

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

packages/guard-shim-react18/src/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,15 @@ export class Guard {
454454
const authClient = await this.getAuthClient()
455455

456456
const idToken =
457-
authClient.tokenProvider.getToken() || localStorage.getItem('idToken')
457+
authClient.tokenProvider.getToken() ||
458+
localStorage.getItem('idToken') ||
459+
''
458460

459461
if (!idToken) {
460-
return null
462+
const user = await authClient.getCurrentUser()
463+
if (user) {
464+
return user
465+
}
461466
}
462467

463468
const publicConfig = await this.then()

packages/guard/src/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,15 @@ export class Guard {
452452
const authClient = await this.getAuthClient()
453453

454454
const idToken =
455-
authClient.tokenProvider.getToken() || localStorage.getItem('idToken')
455+
authClient.tokenProvider.getToken() ||
456+
localStorage.getItem('idToken') ||
457+
''
456458

457459
if (!idToken) {
458-
return null
460+
const user = await authClient.getCurrentUser()
461+
if (user) {
462+
return user
463+
}
459464
}
460465

461466
const publicConfig = await this.then()

0 commit comments

Comments
 (0)