Load profile after refresh
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2023-03-07 14:14:14 +01:00
parent 7c8c16362c
commit 3c7adf012f

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy, Inject, Optional,ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core';
import { Component, OnInit, OnDestroy, Inject, Optional, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core';
import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
import { Meta, Title, MetaDefinition } from '@angular/platform-browser'; import { DOCUMENT } from "@angular/common";
import { Subscription, Observable } from 'rxjs';
@ -6,7 +6,7 @@ import { distinctUntilChanged } from 'rxjs/operators';
import { Store, Action } from '@ngrx/store';
import { IUser } from '../../models/user';
import { OAuthService, OAuthErrorEvent } from 'angular-oauth2-oidc';
import { FM_COMMON_STARTPAGE} from '../../common.module';
import { FM_COMMON_STARTPAGE } from '../../common.module';
//AppCommon
import { IEventMessage } from '../../models/event.message';
@ -155,14 +155,15 @@ export class AppComponent implements OnInit, OnDestroy {
this.router.navigate(['loggedout'], { queryParams: { redirectTo: this.router.url } });
}
}
if(event.type == 'token_received') {
if (event.type == 'token_received') {
this.oauthService$.loadUserProfile();
this.store$.dispatch(new commonActions.InitUser());
}
});
if(this.oauthService$.hasValidAccessToken()) {
if (this.oauthService$.hasValidAccessToken()) {
this.store$.dispatch(new commonActions.InitUser());
} else {
if(this.oauthService$.getRefreshToken() !=null) {
if (this.oauthService$.getRefreshToken() != null) {
this.oauthService$.refreshToken();
}
}
@ -174,7 +175,7 @@ export class AppComponent implements OnInit, OnDestroy {
if (event instanceof RouteConfigLoadStart) {
other.store$.dispatch(new commonActions.StartRouteLoading());
}
if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content") )) {
if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content"))) {
other.store$.dispatch(new commonActions.SetPageMode(true));
} else if (event instanceof NavigationEnd) {
other.store$.dispatch(new commonActions.SetPageMode(false));