Added idle times in environment files
This commit is contained in:
@@ -20,4 +20,8 @@ export interface Environment {
|
||||
serverUrl: string;
|
||||
environment?: 'DEV' | 'SYS' | 'TEST' | 'ACC' | 'PROD';
|
||||
};
|
||||
idle: {
|
||||
idleAfterMS: number;
|
||||
logoutAfterMS: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { UnsubscribeDirective } from '@msfa-directives/unsubscribe.directive';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { BehaviorSubject, fromEvent, merge, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { AuthenticationService } from './api/authentication.service';
|
||||
@@ -21,10 +22,10 @@ export class IdleService extends UnsubscribeDirective {
|
||||
private _isIdle$ = new BehaviorSubject<boolean>(false);
|
||||
public isIdle$: Observable<boolean> = this._isIdle$.asObservable();
|
||||
private _isActive$ = new BehaviorSubject<boolean>(true);
|
||||
private _timeLeftBeforeLogoutInSeconds$ = new BehaviorSubject<number>(2 * 60);
|
||||
private _idleAfterMS = environment.idle.idleAfterMS;
|
||||
private _autoLogoutAfterMS = environment.idle.logoutAfterMS;
|
||||
private _timeLeftBeforeLogoutInMS$ = new BehaviorSubject<number>(this._autoLogoutAfterMS);
|
||||
|
||||
private _idleAfterMS = 10 * 60 * 1000; // 10 minutes
|
||||
private _autoLogoutAfterMS = 2 * 60 * 1000; // 2 minutes
|
||||
private _idleTimeout;
|
||||
private _autoLogoutTimeout;
|
||||
private _autoLogoutInterval;
|
||||
@@ -60,8 +61,8 @@ export class IdleService extends UnsubscribeDirective {
|
||||
}, this._autoLogoutAfterMS);
|
||||
|
||||
this._autoLogoutInterval = setInterval(() => {
|
||||
const currentTimeLeft = this._timeLeftBeforeLogoutInSeconds$.getValue();
|
||||
this._timeLeftBeforeLogoutInSeconds$.next(currentTimeLeft - 1);
|
||||
const currentTimeLeft = this._timeLeftBeforeLogoutInMS$.getValue();
|
||||
this._timeLeftBeforeLogoutInMS$.next(currentTimeLeft - 1000);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ export class IdleService extends UnsubscribeDirective {
|
||||
clearTimeout(this._autoLogoutTimeout);
|
||||
clearTimeout(this._idleTimeout);
|
||||
clearInterval(this._autoLogoutInterval);
|
||||
this._timeLeftBeforeLogoutInSeconds$.next(2 * 60);
|
||||
this._timeLeftBeforeLogoutInMS$.next(this._autoLogoutAfterMS);
|
||||
}
|
||||
|
||||
public setActive(): void {
|
||||
@@ -80,8 +81,9 @@ export class IdleService extends UnsubscribeDirective {
|
||||
}
|
||||
|
||||
public get timeLeftBeforeLogout$(): Observable<string> {
|
||||
return this._timeLeftBeforeLogoutInSeconds$.pipe(
|
||||
map(timeLeftInSeconds => {
|
||||
return this._timeLeftBeforeLogoutInMS$.pipe(
|
||||
map(timeLeftInMS => {
|
||||
const timeLeftInSeconds = timeLeftInMS / 1000;
|
||||
const minutes = Math.floor(timeLeftInSeconds / 60);
|
||||
const seconds = timeLeftInSeconds - minutes * 60;
|
||||
|
||||
|
||||
@@ -17,4 +17,8 @@ export const environment: Environment = {
|
||||
environment: 'ACC',
|
||||
},
|
||||
ciam: CIAM_TEST,
|
||||
idle: {
|
||||
idleAfterMS: 10 * 60 * 1000, // 10 minutes
|
||||
logoutAfterMS: 2 * 60 * 1000, // 2 minutes
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,4 +13,8 @@ export const environment: Environment = {
|
||||
},
|
||||
activeFeatures: [...ACTIVE_FEATURES_TEST, Feature.MOCK_LOGIN],
|
||||
ciam: CIAM_MOCK,
|
||||
idle: {
|
||||
idleAfterMS: 10 * 60 * 1000, // 10 minutes
|
||||
logoutAfterMS: 2 * 60 * 1000, // 2 minutes
|
||||
},
|
||||
};
|
||||
|
||||
@@ -17,4 +17,8 @@ export const environment: Environment = {
|
||||
environment: 'PROD',
|
||||
},
|
||||
ciam: CIAM_PROD,
|
||||
idle: {
|
||||
idleAfterMS: 10 * 60 * 1000, // 10 minutes
|
||||
logoutAfterMS: 2 * 60 * 1000, // 2 minutes
|
||||
},
|
||||
};
|
||||
|
||||
@@ -17,4 +17,8 @@ export const environment: Environment = {
|
||||
environment: 'DEV',
|
||||
},
|
||||
ciam: CIAM_TEST,
|
||||
idle: {
|
||||
idleAfterMS: 60 * 60 * 1000, // 60 minutes
|
||||
logoutAfterMS: 10 * 60 * 1000, // 10 minutes
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user