[ADF-4665] [ADF] - Application is refreshed when you have two instances of application opened (#4849)

* refactoring getValueFromToken and fix user token refresh

* refactoring getValueFromToken and fix user token refresh

* refactoring getValueFromToken and fix user token refres

* fix unit test
This commit is contained in:
Eugenio Romano
2019-06-14 16:02:12 +01:00
committed by GitHub
parent 4733bc7d3b
commit f47cebc0a4
11 changed files with 94 additions and 93 deletions

View File

@@ -21,6 +21,7 @@ import { AuthenticationService } from './authentication.service';
import { Observable } from 'rxjs';
import { AppConfigService } from '../app-config/app-config.service';
import { AuthGuardBase } from './auth-guard-base';
import { JwtHelperService } from './jwt-helper.service';
@Injectable({
providedIn: 'root'
@@ -29,7 +30,8 @@ export class AuthGuard extends AuthGuardBase {
ticketChangeBind: any;
constructor(authenticationService: AuthenticationService,
constructor(private jwtHelperService: JwtHelperService,
authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService) {
super(authenticationService, router, appConfigService);
@@ -47,7 +49,9 @@ export class AuthGuard extends AuthGuardBase {
this.ticketChangeRedirect(event, 'BPM');
}
if (event.key === 'id_token' && event.newValue !== event.oldValue) {
if (event.key === JwtHelperService.USER_ACCESS_TOKEN &&
this.jwtHelperService.getValueFromToken(event.newValue, JwtHelperService.USER_PREFERRED_USERNAME) !==
this.jwtHelperService.getValueFromToken(event.oldValue, JwtHelperService.USER_PREFERRED_USERNAME)) {
this.ticketChangeRedirect(event, 'ALL');
}
}