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

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

Pull request #140: [EDELIVERY-13756] UI - add missing expired session alert

Merge in EDELIVERY/smp from EDELIVERY-13756-user-should-be-informed-after-is-logged-out-due-to-session-expiration to development

* commit 'b761db72':
  [EDELIVERY-13758] UI show session extension in minutes and seconds
  [EDELIVERY-13756] UI - add missing expired session alert
parents d6d7e6fa b761db72
No related branches found
No related tags found
No related merge requests found
<h2 mat-dialog-title>{{ "session.expiration.dialog.title" | translate }}</h2>
<mat-dialog-content>
<div innerHTML='{{"session.expiration.dialog.label.session.about.to.expire" | translate:{timeLeft: data.timeLeft, timeout: data.timeout} }}'></div>
<div innerHTML='{{"session.expiration.dialog.label.session.about.to.expire" | translate:{timeLeft: data.timeLeft,
timeoutMinutes: sessionDurationInMinutes, timeoutSeconds: sessionDurationInMinutesReminder} }}'></div>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-raised-button mat-dialog-close (click)="onLogoutClicked()" tabindex="-1">
......
......@@ -24,5 +24,13 @@ export class SessionExpirationDialogComponent {
this.securityService.logout();
this.dialogRef.close();
}
get sessionDurationInMinutes() {
return Math.floor(this.data.timeout / 60);
}
get sessionDurationInMinutesReminder() {
return this.data.timeout % 60;
}
}
......@@ -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, {
......
......@@ -92,7 +92,8 @@
"session.expiration.dialog.button.expire": "Extend",
"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.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<br /> for another <b>{{timeoutMinutes}}</b> minute(s) and <b>{{timeoutSeconds}}</b> second(s)?",
"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