79700: specs for modal, auth check for idleness tracking & stop blocking at token success

This commit is contained in:
Marie Verdonck
2021-06-03 14:29:50 +02:00
parent 38387d1a0f
commit e88baa1995
6 changed files with 151 additions and 18 deletions

View File

@@ -2,7 +2,12 @@ import { map, take } from 'rxjs/operators';
import { Component, Inject, OnInit, Optional, Input } from '@angular/core';
import { Router } from '@angular/router';
import { combineLatest as combineLatestObservable, Observable, of } from 'rxjs';
import {
combineLatest as observableCombineLatest,
combineLatest as combineLatestObservable,
Observable,
of
} from 'rxjs';
import { Store } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
@@ -84,18 +89,19 @@ export class RootComponent implements OnInit {
map(([collapsed, mobile]) => collapsed || mobile)
);
this.authService.isUserIdle().subscribe((userIdle: boolean) => {
if (userIdle) {
if (!this.idleModalOpen) {
const modalRef = this.modalService.open(IdleModalComponent);
this.idleModalOpen = true;
modalRef.componentInstance.response.pipe(take(1)).subscribe((closed: boolean) => {
if (closed) {
this.idleModalOpen = false;
}
});
observableCombineLatest([this.authService.isUserIdle(), this.authService.isAuthenticated()])
.subscribe(([userIdle, authenticated]) => {
if (userIdle && authenticated) {
if (!this.idleModalOpen) {
const modalRef = this.modalService.open(IdleModalComponent);
this.idleModalOpen = true;
modalRef.componentInstance.response.pipe(take(1)).subscribe((closed: boolean) => {
if (closed) {
this.idleModalOpen = false;
}
});
}
}
}
});
}
}