Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 53a7c0e6 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[EDELIVERY-13756] UI - add missing expired session alert

parent ef56836a
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import {MatDialog} from "@angular/material/dialog";
import {
SessionExpirationDialogComponent
} from "../common/dialogs/session-expiration-dialog/session-expiration-dialog.component";
import {TranslateService} from "@ngx-translate/core";
/*
* A custom interceptor that handles session expiration before it happens.
......@@ -26,6 +27,8 @@ export class HttpSessionInterceptor implements HttpInterceptor {
private timerToLogoutId: number;
constructor(public securityService: SecurityService,
private alertService: AlertMessageService,
private translateService: TranslateService,
private dialog: MatDialog) {
}
......@@ -33,7 +36,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
clearTimeout(this.timerId);
clearTimeout(this.timerToLogoutId);
let user = this.securityService.getCurrentUser();
if (user && user.sessionMaxIntervalTimeoutInSeconds && user.sessionMaxIntervalTimeoutInSeconds > this.TIME_BEFORE_EXPIRATION_IN_SECONDS) {
if (user?.sessionMaxIntervalTimeoutInSeconds && user.sessionMaxIntervalTimeoutInSeconds > this.TIME_BEFORE_EXPIRATION_IN_SECONDS) {
let timeout = Math.min((user.sessionMaxIntervalTimeoutInSeconds - this.TIME_BEFORE_EXPIRATION_IN_SECONDS) * 1000, this.MAXIMUM_TIMEOUT_VALUE);
this.timerId = setTimeout(() => this.sessionExpiringSoon(user.sessionMaxIntervalTimeoutInSeconds), timeout);
}
......@@ -44,6 +47,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
// Logout the user after the session expires
this.timerToLogoutId = setTimeout(() => {
this.securityService.logout();
this.alertService.errorForTranslation("session.alert.message.logout.expired", true);
}, this.TIME_BEFORE_EXPIRATION_IN_SECONDS * 1000);
this.dialog.open(SessionExpirationDialogComponent, {
......
......@@ -93,6 +93,7 @@
"session.expiration.dialog.button.logout": "Logout",
"session.expiration.dialog.title": "Extend session",
"session.expiration.dialog.label.session.about.to.expire": "Your session is about to expire in <b>{{timeLeft}}</b> seconds!<br />Would you like to logout now or extend it for another <b>{{timeout}}</b> seconds?",
"session.alert.message.logout.expired": "Your session has expired, and you have been logged out",
"alert.panel.title": "Alerts",
"alert.panel.user.title": "{{value}} (Email: '{{mailTo}}')",
"certificate.panel.title": "Selected certificate data",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment