From 07e42f915e72d7496a592a2c7446b799c6a17bb9 Mon Sep 17 00:00:00 2001 From: Masum ULU Date: Mon, 4 Sep 2023 08:31:26 +0300 Subject: [PATCH] Remove confirmation for 401 status code --- .../packages/oauth/src/lib/guards/oauth.guard.ts | 7 +++---- .../lib/services/status-code-error-handler.service.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts b/npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts index faafafedfa..2571a1756c 100644 --- a/npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts +++ b/npm/ng-packs/packages/oauth/src/lib/guards/oauth.guard.ts @@ -1,11 +1,10 @@ import { Injectable, inject } from '@angular/core'; 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 { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core'; +import { AuthService, IAbpGuard } from '@abp/ng.core'; @Injectable({ providedIn: 'root', @@ -13,7 +12,6 @@ import { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core'; export class AbpOAuthGuard implements IAbpGuard { protected readonly oAuthService = inject(OAuthService); protected readonly authService = inject(AuthService); - protected readonly httpErrorReporter = inject(HttpErrorReporterService); canActivate( route: ActivatedRouteSnapshot, @@ -23,6 +21,7 @@ export class AbpOAuthGuard implements IAbpGuard { if (hasValidAccessToken) { return true; } + const params = { returnUrl: state.url }; this.authService.navigateToLogin(params); return false; diff --git a/npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts b/npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts index 6acaff0a92..e11f5daacf 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/services/status-code-error-handler.service.ts @@ -78,15 +78,16 @@ export class StatusCodeErrorHandlerService implements CustomHttpErrorHandlerServ switch (this.status) { case 401: case 404: + if (this.status === 401) { + this.authService.navigateToLogin(); + return; + } + if (canCreateCustomError) { this.showPage(); break; } - this.showConfirmation(title, message).subscribe(() => { - if (this.status === 401) { - this.navigateToLogin(); - } - }); + this.showConfirmation(title, message).subscribe(); break; case 403: