From f700cdc5162f45904b14ebac1b8d80929f061604 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Thu, 11 Dec 2025 13:54:47 +0530 Subject: [PATCH 1/2] fix: amm-1931 session expiry --- .../http-interceptor.service.ts | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app/core/services/httpInterceptor/http-interceptor.service.ts b/src/app/core/services/httpInterceptor/http-interceptor.service.ts index c8d9029a..97571eec 100644 --- a/src/app/core/services/httpInterceptor/http-interceptor.service.ts +++ b/src/app/core/services/httpInterceptor/http-interceptor.service.ts @@ -82,7 +82,26 @@ export class HttpInterceptorService implements HttpInterceptor { }), catchError((error: HttpErrorResponse) => { console.error(error); - + if (error.status === 401) { + this.confirmationService.alert( + this.currentLanguageSet.sessionExpiredPleaseLogin || 'Your session has expired. Please login again.', + ); + } else if (error.status === 403) { + this.confirmationService.alert( + this.currentLanguageSet.accessDenied || 'You do not have permission to access this resource.', + 'error', + ); + } else if (error.status === 500) { + this.confirmationService.alert( + this.currentLanguageSet.internaleServerError || 'Internal server error occurred. Please try again later.', + 'error', + ); + } else { + this.confirmationService.alert( + error.message || this.currentLanguageSet.somethingWentWrong || 'Something went wrong. Please try again later.', + 'error', + ); + } this.spinnerService.setLoading(false); return throwError(error.error); }), @@ -110,7 +129,6 @@ export class HttpInterceptorService implements HttpInterceptor { console.log('there', Date()); if ( - this.sessionstorage.getItem('authenticationToken') && sessionStorage.getItem('isAuthenticated') ) { this.confirmationService @@ -130,7 +148,7 @@ export class HttpInterceptorService implements HttpInterceptor { this.sessionstorage.clear(); localStorage.clear(); this.confirmationService.alert( - this.currentLanguageSet.sessionExpired, + this.currentLanguageSet.sessionExpired || 'Your session has expired. Please login again.', 'error', ); this.router.navigate(['/login']); @@ -140,7 +158,7 @@ export class HttpInterceptorService implements HttpInterceptor { this.sessionstorage.clear(); localStorage.clear(); this.confirmationService.alert( - this.currentLanguageSet.sessionExpired, + this.currentLanguageSet.sessionExpired || 'Your session has expired. Please login again.', 'error', ); this.router.navigate(['/login']); From 8487714d1d59607bce6d30696f08cbbffdf93d9d Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Thu, 11 Dec 2025 16:53:09 +0530 Subject: [PATCH 2/2] fix: amm-1931 handled error messages --- .../httpInterceptor/http-interceptor.service.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/app/core/services/httpInterceptor/http-interceptor.service.ts b/src/app/core/services/httpInterceptor/http-interceptor.service.ts index 97571eec..0599f51a 100644 --- a/src/app/core/services/httpInterceptor/http-interceptor.service.ts +++ b/src/app/core/services/httpInterceptor/http-interceptor.service.ts @@ -82,26 +82,29 @@ export class HttpInterceptorService implements HttpInterceptor { }), catchError((error: HttpErrorResponse) => { console.error(error); - if (error.status === 401) { - this.confirmationService.alert( - this.currentLanguageSet.sessionExpiredPleaseLogin || 'Your session has expired. Please login again.', - ); + if(error.status === 401){ + this.sessionstorage.clear(); + this.confirmationService.alert('Session expired. Please login again.', 'error'); + } else if (error.status === 403) { this.confirmationService.alert( - this.currentLanguageSet.accessDenied || 'You do not have permission to access this resource.', + 'Access Denied', 'error', ); } else if (error.status === 500) { this.confirmationService.alert( - this.currentLanguageSet.internaleServerError || 'Internal server error occurred. Please try again later.', + 'Internal Server Error', 'error', ); } else { this.confirmationService.alert( - error.message || this.currentLanguageSet.somethingWentWrong || 'Something went wrong. Please try again later.', + error.message || 'Something went wrong', 'error', ); } + this.router.navigate(['/login']); + sessionStorage.clear(); + this.sessionstorage.clear(); this.spinnerService.setLoading(false); return throwError(error.error); }),