Check token when going online
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
				
			This commit is contained in:
		| @@ -162,6 +162,25 @@ export class AppCommonEffects { | ||||
|       return null; | ||||
|     })); | ||||
|  | ||||
|     @Effect({ dispatch: false }) | ||||
|     online$: Observable<Action> = this.actions$.pipe( | ||||
|       ofType(appCommonActions.ONLINE), | ||||
|       map((action) => { | ||||
|         console.debug("Online: Check token"); | ||||
|         if(!this.oauthService$.hasValidAccessToken()) { | ||||
|           console.debug("No valid token, try to refresh"); | ||||
|           if(this.oauthService$.getRefreshToken() != null ) { | ||||
|             console.debug("We have a refresh token"); | ||||
|             this.oauthService$.refreshToken().then(() => {               | ||||
|               this.store$.dispatch(new appCommonActions.InitUser()); | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|         return null; | ||||
|       })); | ||||
|  | ||||
|  | ||||
|  | ||||
|   constructor(private actions$: Actions, private store$: Store<appCommonReducers.State>, private oauthService$: OAuthService, private itemService$: ItemService, private folderService$:FolderService, private userService$: UserService, private router$: Router, private stateSerializerService$:StateSerializerService) { | ||||
|     store$.dispatch(new appCommonActions.LoadItemTypes()); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user