From 987a917ca1e46e48dedbff63ef690767566df5f7 Mon Sep 17 00:00:00 2001 From: Jason Gregory Date: Fri, 29 Sep 2017 08:02:40 -0400 Subject: [PATCH] Fixed two issues when responseType is id_token only: 1. Check to make sure that tokens is an array before calling .forEach inside handleAuthentication 2. Return true for isAuthenticated if either an access_token or an id_token exists --- packages/okta-angular/src/okta/okta.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/okta-angular/src/okta/okta.service.ts b/packages/okta-angular/src/okta/okta.service.ts index e456a5fdd..7b7b95ca3 100644 --- a/packages/okta-angular/src/okta/okta.service.ts +++ b/packages/okta-angular/src/okta/okta.service.ts @@ -63,10 +63,10 @@ export class OktaAuthService { } /** - * Checks if there is a current accessToken in the TokenManager. + * Checks if there is a current accessToken or idToken in the TokenManager. */ isAuthenticated() { - return !!this.oktaAuth.tokenManager.get('accessToken'); + return !!this.oktaAuth.tokenManager.get('accessToken') || !!this.oktaAuth.tokenManager.get('idToken'); } /** @@ -114,7 +114,8 @@ export class OktaAuthService { * Parses the tokens from the callback URL. */ async handleAuthentication() { - const tokens = await this.oktaAuth.token.parseFromUrl(); + let tokens = await this.oktaAuth.token.parseFromUrl(); + tokens = Object.prototype.toString.call(tokens) === '[object Array]' ? tokens : [tokens]; tokens.forEach(token => { if (token.idToken) { this.oktaAuth.tokenManager.add('idToken', token);