-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19664 from abpframework/auto-merge/prerel-8-2/2665
Merge branch dev with prerel-8.2
- Loading branch information
Showing
4 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { inject, Injectable } from '@angular/core'; | ||
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'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class AbpAuthenticationErrorHandler implements CustomHttpErrorHandlerService { | ||
readonly priority = CUSTOM_HTTP_ERROR_HANDLER_PRIORITY.veryHigh; | ||
protected readonly authService = inject(AuthService); | ||
protected readonly configStateService = inject(ConfigStateService); | ||
|
||
canHandle(error: unknown): boolean { | ||
return error instanceof HttpErrorResponse && error.status === 401; | ||
} | ||
|
||
execute() { | ||
this.configStateService.refreshAppState().subscribe(({ currentUser }) => { | ||
if (!currentUser.isAuthenticated) { | ||
this.authService.logout(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters