|
|
|
@ -3,11 +3,13 @@ import { AuthService, ConfigStateService } from '@abp/ng.core'; |
|
|
|
import { HttpErrorResponse } from '@angular/common/http'; |
|
|
|
import { CustomHttpErrorHandlerService } from '../models/common'; |
|
|
|
import { CUSTOM_HTTP_ERROR_HANDLER_PRIORITY } from '../constants/default-errors'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' }) |
|
|
|
export class AbpAuthenticationErrorHandler implements CustomHttpErrorHandlerService { |
|
|
|
readonly priority = CUSTOM_HTTP_ERROR_HANDLER_PRIORITY.veryHigh; |
|
|
|
protected readonly authService = inject(AuthService); |
|
|
|
protected readonly router = inject(Router); |
|
|
|
protected readonly configStateService = inject(ConfigStateService); |
|
|
|
|
|
|
|
canHandle(error: unknown): boolean { |
|
|
|
@ -17,7 +19,7 @@ export class AbpAuthenticationErrorHandler implements CustomHttpErrorHandlerServ |
|
|
|
execute() { |
|
|
|
this.configStateService.refreshAppState().subscribe(({ currentUser }) => { |
|
|
|
if (!currentUser.isAuthenticated) { |
|
|
|
this.authService.logout(); |
|
|
|
this.authService.logout({ noRedirectToLogoutUrl: true }); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|