Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/app/core/services/httpInterceptor/http-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,29 @@ export class HttpInterceptorService implements HttpInterceptor {
}),
catchError((error: HttpErrorResponse) => {
console.error(error);

if(error.status === 401){
this.sessionstorage.clear();
this.confirmationService.alert('Session expired. Please login again.', 'error');

} else if (error.status === 403) {
this.confirmationService.alert(
'Access Denied',
'error',
);
} else if (error.status === 500) {
this.confirmationService.alert(
'Internal Server Error',
'error',
);
} else {
this.confirmationService.alert(
error.message || 'Something went wrong',
'error',
);
}
this.router.navigate(['/login']);
sessionStorage.clear();
this.sessionstorage.clear();
this.spinnerService.setLoading(false);
return throwError(error.error);
}),
Expand Down Expand Up @@ -110,7 +132,6 @@ export class HttpInterceptorService implements HttpInterceptor {
console.log('there', Date());

if (
this.sessionstorage.getItem('authenticationToken') &&
sessionStorage.getItem('isAuthenticated')
) {
this.confirmationService
Expand All @@ -130,7 +151,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']);
Expand All @@ -140,7 +161,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']);
Expand Down