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
Branches bugfix/EDELIVERY-13125-remove-caching-of-the-keys
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import {MatDialog} from "@angular/material/dialog"; ...@@ -7,6 +7,7 @@ import {MatDialog} from "@angular/material/dialog";
import { import {
SessionExpirationDialogComponent SessionExpirationDialogComponent
} from "../common/dialogs/session-expiration-dialog/session-expiration-dialog.component"; } 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. * A custom interceptor that handles session expiration before it happens.
...@@ -26,6 +27,8 @@ export class HttpSessionInterceptor implements HttpInterceptor { ...@@ -26,6 +27,8 @@ export class HttpSessionInterceptor implements HttpInterceptor {
private timerToLogoutId: number; private timerToLogoutId: number;
constructor(public securityService: SecurityService, constructor(public securityService: SecurityService,
private alertService: AlertMessageService,
private translateService: TranslateService,
private dialog: MatDialog) { private dialog: MatDialog) {
} }
...@@ -33,7 +36,7 @@ export class HttpSessionInterceptor implements HttpInterceptor { ...@@ -33,7 +36,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
clearTimeout(this.timerId); clearTimeout(this.timerId);
clearTimeout(this.timerToLogoutId); clearTimeout(this.timerToLogoutId);
let user = this.securityService.getCurrentUser(); 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); 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); this.timerId = setTimeout(() => this.sessionExpiringSoon(user.sessionMaxIntervalTimeoutInSeconds), timeout);
} }
...@@ -44,6 +47,7 @@ export class HttpSessionInterceptor implements HttpInterceptor { ...@@ -44,6 +47,7 @@ export class HttpSessionInterceptor implements HttpInterceptor {
// Logout the user after the session expires // Logout the user after the session expires
this.timerToLogoutId = setTimeout(() => { this.timerToLogoutId = setTimeout(() => {
this.securityService.logout(); this.securityService.logout();
this.alertService.errorForTranslation("session.alert.message.logout.expired", true);
}, this.TIME_BEFORE_EXPIRATION_IN_SECONDS * 1000); }, this.TIME_BEFORE_EXPIRATION_IN_SECONDS * 1000);
this.dialog.open(SessionExpirationDialogComponent, { this.dialog.open(SessionExpirationDialogComponent, {
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
"session.expiration.dialog.button.logout": "Logout", "session.expiration.dialog.button.logout": "Logout",
"session.expiration.dialog.title": "Extend session", "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.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.title": "Alerts",
"alert.panel.user.title": "{{value}} (Email: '{{mailTo}}')", "alert.panel.user.title": "{{value}} (Email: '{{mailTo}}')",
"certificate.panel.title": "Selected certificate data", "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