From 154de1f9911772ddb2ab6abb955c064489f723f5 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 6 Apr 2026 10:24:35 +0100 Subject: [PATCH] call sesstion exparation model --- src/app/app.module.ts | 4 ++- .../interceptors/token.interceptors.ts | 30 ++++++++----------- src/global.scss | 13 ++++++++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 963e8eaab..3ee387611 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -88,6 +88,7 @@ import { ChatModule } from './module/chat/chat.module'; import { registerLocaleData } from '@angular/common'; import localePt from '@angular/common/locales/pt'; import { UserModule } from './module/user/user.module'; +import { SessionExpiredModalPageModule } from './modals/session-expired-modal/session-expired-modal.module'; import { Logger } from './services/logger/main/service'; registerLocaleData(localePt, 'pt'); @@ -369,7 +370,8 @@ registerLocaleData(localePt, 'pt'); MatIconModule, // module ChatModule, - UserModule + UserModule, + SessionExpiredModalPageModule ], entryComponents: [ DiplomaOptionsPage, diff --git a/src/app/infra/monitoring/interceptors/token.interceptors.ts b/src/app/infra/monitoring/interceptors/token.interceptors.ts index 8f3b3409d..1f4aa220b 100644 --- a/src/app/infra/monitoring/interceptors/token.interceptors.ts +++ b/src/app/infra/monitoring/interceptors/token.interceptors.ts @@ -13,8 +13,8 @@ import { catchError, filter, take, switchMap, tap } from "rxjs/operators"; import { SessionStore } from '../../../store/session.service'; import { environment } from "src/environments/environment"; import { Router } from "@angular/router"; -import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { Platform } from '@ionic/angular'; +import { SessionExpiredModalService } from 'src/app/services/session-expired-modal.service'; import { UserLoginOutputResponse } from "../../../core/user/repository/user-remote-repository"; @Injectable() @@ -29,7 +29,7 @@ export class TokenInterceptor implements HttpInterceptor { constructor( private http: HttpClient, private router: Router, - private httpErrorHandle: HttpErrorHandle, + private sessionExpiredModal: SessionExpiredModalService, private platform: Platform) { } @@ -132,23 +132,19 @@ export class TokenInterceptor implements HttpInterceptor { }), catchError((error) => { console.log("refresh token error",error) - // SessionStore.user.Authorization = SessionStore.user.Authorization; - // SessionStore.user.RefreshToken = SessionStore.user.RefreshToken; SessionStore.setInativity(false) - /* SessionStore.setUrlBeforeInactivity(this.router.url); */ - if (environment.production) { - window.location.pathname = '/auth' - } else { - const pathBeforeGoOut = window.location.pathname - console.log('Before auth',window.location.pathname) - this.router.navigateByUrl('/auth', { replaceUrl: true }).then(() =>{ - if(pathBeforeGoOut != "/auth") { - this.httpErrorHandle.httpsSucessMessagge('sessonExpired') - } - - }) - } + const sessionExpiredMessage = + 'A sua sessão expirou. Por favor, faça login novamente para continuar.'; + const goToAuth = () => { + if (environment.production) { + window.location.pathname = '/auth'; + } else if (!this.router.url.startsWith('/auth')) { + this.router.navigateByUrl('/auth', { replaceUrl: true }); + } + }; + console.log('sessionExpiredModal', this.sessionExpiredModal) + void this.sessionExpiredModal.present(sessionExpiredMessage, goToAuth); return of(false); }) ); diff --git a/src/global.scss b/src/global.scss index 13298ccd7..a7021f4d3 100644 --- a/src/global.scss +++ b/src/global.scss @@ -968,6 +968,19 @@ background: rgb(92, 92, 92); display: none !important; } +ion-modal.session-expired-modal-blocking { + --width: 100%; + --height: 100%; + --max-width: 100%; + --max-height: 100%; + --border-radius: 0; + --backdrop-opacity: 0.55; +} + +ion-modal.session-expired-modal-blocking::part(content) { + --background: var(--ion-background-color, #fff); +} + .notification{ position: absolute; top: 23px;