WEB-233: Improve the OIDC integration with 2FA (#2616)
This commit is contained in:
@@ -32,6 +32,8 @@ import { animate, style, transition, trigger } from '@angular/animations';
|
||||
import { I18nService } from './core/i18n/i18n.service';
|
||||
import { ThemingService } from './shared/theme-toggle/theming.service';
|
||||
|
||||
import { AuthService } from './zitadel/auth.service';
|
||||
|
||||
/** Initialize Logger */
|
||||
const log = new Logger('MifosX');
|
||||
|
||||
@@ -90,6 +92,8 @@ export class WebAppComponent implements OnInit {
|
||||
|
||||
i18nService: I18nService;
|
||||
|
||||
isLoggedIn = false;
|
||||
|
||||
/**
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {ActivatedRoute} activatedRoute Activated Route.
|
||||
@@ -117,7 +121,8 @@ export class WebAppComponent implements OnInit {
|
||||
private themingService: ThemingService,
|
||||
private dateUtils: Dates,
|
||||
private idle: IdleTimeoutService,
|
||||
private dialog: MatDialog
|
||||
private dialog: MatDialog,
|
||||
private authService: AuthService
|
||||
) {}
|
||||
|
||||
@HostBinding('class') public cssClass: string;
|
||||
@@ -133,6 +138,11 @@ export class WebAppComponent implements OnInit {
|
||||
*
|
||||
* 4) Alerts
|
||||
*/
|
||||
|
||||
login() {
|
||||
this.authService.login();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.themingService.theme.subscribe((value: string) => {
|
||||
this.cssClass = value;
|
||||
@@ -222,14 +232,18 @@ export class WebAppComponent implements OnInit {
|
||||
// Subscribe to session timeout If IdleTimeout is higher than 0 (zero)
|
||||
if (environment.session.timeout.idleTimeout > 0) {
|
||||
this.idle.$onSessionTimeout.subscribe(() => {
|
||||
if (this.authenticationService.getUserLoggedIn()) {
|
||||
this.alertService.alert({
|
||||
type: 'Session timeout',
|
||||
message: this.translateService.instant('labels.text.Session timed out')
|
||||
});
|
||||
this.dialog.open(SessionTimeoutDialogComponent);
|
||||
this.logout();
|
||||
}
|
||||
this.alertService.alert({
|
||||
type: 'Session timeout',
|
||||
message: this.translateService.instant('labels.text.Session timed out')
|
||||
});
|
||||
this.dialog.open(SessionTimeoutDialogComponent);
|
||||
setTimeout(() => {
|
||||
if (environment.OIDC.oidcServerEnabled) {
|
||||
this.logout();
|
||||
} else {
|
||||
this.authService.logout();
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user