[ADF-4637] logout cross tabs event (#4823)

* logout cross tabs event

* fix remove listner

* fix remove listner

* Update auth-guard.service.ts
This commit is contained in:
Eugenio Romano 2019-06-10 19:37:28 +01:00 committed by GitHub
parent 105a1a2b28
commit cb37254cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 4 deletions

View File

@ -26,7 +26,7 @@ import { StorageService } from './storage.service';
export class AuthGuardSsoRoleService implements CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let hasRole = false;
let hasRole;
let hasRealmRole = false;
let hasClientRole = true;

View File

@ -66,7 +66,7 @@ describe('AuthGuardService', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(authGuard.canActivate(null, route)).toBeTruthy();
}));

View File

@ -26,10 +26,40 @@ import { AuthGuardBase } from './auth-guard-base';
providedIn: 'root'
})
export class AuthGuard extends AuthGuardBase {
ticketChangeBind: any;
constructor(authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService) {
super(authenticationService, router, appConfigService);
this.ticketChangeBind = this.ticketChange.bind(this);
window.addEventListener('storage', this.ticketChangeBind);
}
ticketChange(event: StorageEvent) {
if (event.key === 'ticket-ECM' && event.newValue !== event.oldValue) {
this.ticketChangeRedirect(event, 'ECM');
}
if (event.key === 'ticket-BPM' && event.newValue !== event.oldValue) {
this.ticketChangeRedirect(event, 'BPM');
}
if (event.key === 'access_token' && event.newValue !== event.oldValue) {
this.ticketChangeRedirect(event, 'ALL');
}
}
private ticketChangeRedirect(event: StorageEvent, provider: string) {
if (!event.newValue) {
this.redirectToUrl(provider, this.router.url);
} else {
window.location.reload();
}
window.removeEventListener('storage', this.ticketChangeBind);
}
checkLogin(activeRoute: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {

View File

@ -25,11 +25,11 @@ while [[ $1 == -* ]]; do
esac
done
COMPONENTS_ROOT="$DIR/../lib"
COMPONENTS_ROOT="$DIR/../../lib"
# Find all directories in $COMPONENTS_ROOT called i18n and add the demo-shell manually
COMPONENTS=(`find $COMPONENTS_ROOT -type d -name i18n -not \( -name '*.*' -o -path '**/node_modules*' -o -path '**/bundles*' \)`)
COMPONENTS+=("$DIR/../demo-shell/resources/i18n")
COMPONENTS+=("$DIR/../../demo-shell/resources/i18n")
# Loop the individual components
for COMPONENT_DIR in "${COMPONENTS[@]}"