diff --git a/projects/common/src/fm/services/auth-guard.service.ts b/projects/common/src/fm/services/auth-guard.service.ts index 2722c0b..9bd84c7 100644 --- a/projects/common/src/fm/services/auth-guard.service.ts +++ b/projects/common/src/fm/services/auth-guard.service.ts @@ -40,19 +40,24 @@ export class AuthGuard implements CanActivate, CanLoad, CanActivateChild { checkLogin(url: string): Promise { return new Promise((resolve) => { if (!this.oauthService.hasValidAccessToken()) { + console.debug("No valid token"); if(this.oauthService.getRefreshToken() != null ) { + console.debug("We have a refresh token"); this.oauthService.refreshToken().then(() => { this.store.dispatch(new appCommonActions.InitUser()); resolve(true); }).catch(() => { - resolve(false); + console.debug("Error refreshing"); this.oauthService.initCodeFlow(url); + resolve(false); }) } else { - resolve(false); + console.debug("No refresh token"); this.oauthService.initCodeFlow(url); + resolve(false); } } else { + console.debug("Valid token init user"); this.store.dispatch(new appCommonActions.InitUser()); return(true); }