Browse Source

Merge pull request #17544 from abpframework/issue-17529

AngularUI: Remove confirmation for 401 status code
pull/17556/head
Masum ULU 3 years ago
committed by GitHub
parent
commit
dc20070f7c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts
  2. 12
      npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts

7
npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts

@ -1,11 +1,10 @@
import { Injectable, inject } from '@angular/core'; import { Injectable, inject } from '@angular/core';
import { UrlTree, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { UrlTree, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { HttpErrorResponse } from '@angular/common/http';
import { Observable, delay, of, tap } from 'rxjs'; import { Observable } from 'rxjs';
import { OAuthService } from 'angular-oauth2-oidc'; import { OAuthService } from 'angular-oauth2-oidc';
import { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core'; import { AuthService, IAbpGuard } from '@abp/ng.core';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -13,7 +12,6 @@ import { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core';
export class AbpOAuthGuard implements IAbpGuard { export class AbpOAuthGuard implements IAbpGuard {
protected readonly oAuthService = inject(OAuthService); protected readonly oAuthService = inject(OAuthService);
protected readonly authService = inject(AuthService); protected readonly authService = inject(AuthService);
protected readonly httpErrorReporter = inject(HttpErrorReporterService);
canActivate( canActivate(
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
@ -23,6 +21,7 @@ export class AbpOAuthGuard implements IAbpGuard {
if (hasValidAccessToken) { if (hasValidAccessToken) {
return true; return true;
} }
const params = { returnUrl: state.url }; const params = { returnUrl: state.url };
this.authService.navigateToLogin(params); this.authService.navigateToLogin(params);
return false; return false;

12
npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts

@ -82,11 +82,13 @@ export class StatusCodeErrorHandlerService implements CustomHttpErrorHandlerServ
this.showPage(); this.showPage();
break; break;
} }
this.showConfirmation(title, message).subscribe(() => {
if (this.status === 401) { if (this.status === 401) {
this.navigateToLogin(); this.authService.navigateToLogin();
} break;
}); }
this.showConfirmation(title, message).subscribe();
break; break;
case 403: case 403:

Loading…
Cancel
Save