Skip to content

Commit f252aec

Browse files
authored
fix: improve token handling and userinfo display logic (#92)
1 parent 346122c commit f252aec

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@
218218
// const token = await fetchToken()
219219
if (!token) throw new Error('Did not get response from token endpoint');
220220
authzResponse.token = token;
221-
222-
const { payload: profile } = parseToken(token.id_token);
221+
if (!token.id_token && !token.access_token) throw new Error('Did not get token');
222+
const { payload: profile } = parseToken(token.id_token || token.access_token);
223223
if (!profile) throw new Error('Did not get profile from token');
224224
authzResponse.parsed = profile;
225225

src/lib/components/AuthorizationResponse.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/>
3434
{/if}
3535

36-
{#if authzResponse.userinfo}
36+
{#if authzResponse.token?.id_token && authzResponse.userinfo}
3737
<JsonResponse label={new URL('/oauth/userinfo', authzUrl)} json={authzResponse.userinfo} />
3838
{/if}
3939

0 commit comments

Comments
 (0)