Add some debug logging
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good Details

feature/MinimizeSolution
Willem Dantuma 2020-05-11 20:50:38 +02:00
parent b70ec77328
commit 1c8db3ac94
1 changed files with 7 additions and 2 deletions

View File

@ -40,19 +40,24 @@ export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
checkLogin(url: string): Promise<boolean> {
return new Promise<boolean>((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);
}