From e46ba45867829e423525371d74b7d73d3347572d Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Fri, 3 May 2024 14:51:44 +0300 Subject: [PATCH 1/3] pass `noRedirectToLogoutUrl` parameter to logout method --- .../oauth/src/lib/strategies/auth-code-flow-strategy.ts | 6 +++++- .../lib/services/authentication-error-handler.service.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts b/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts index 7b1e0c108a..61b35f9441 100644 --- a/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts +++ b/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts @@ -1,6 +1,6 @@ import { noop } from '@abp/ng.core'; import { Params } from '@angular/router'; -import { from, of } from 'rxjs'; +import { Observable, from, of } from 'rxjs'; import { AuthFlowStrategy } from './auth-flow-strategy'; import { isTokenExpired } from '../utils'; @@ -51,6 +51,10 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy { logout(queryParams?: Params) { this.rememberMeService.remove(); + if (queryParams?.noRedirectToLogoutUrl) { + this.router.navigate(['/']); + return from(this.oAuthService.revokeTokenAndLogout(true)); + } return from(this.oAuthService.revokeTokenAndLogout(this.getCultureParams(queryParams))); } diff --git a/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts b/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts index 602514bee8..a3744f1ce7 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts @@ -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 }); } }); } From 5f705b78ca07ca670d74582887be9d72979f2ba5 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Fri, 3 May 2024 14:52:21 +0300 Subject: [PATCH 2/3] remove unused import --- .../oauth/src/lib/strategies/auth-code-flow-strategy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts b/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts index 61b35f9441..0452fdc899 100644 --- a/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts +++ b/npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts @@ -1,6 +1,6 @@ import { noop } from '@abp/ng.core'; import { Params } from '@angular/router'; -import { Observable, from, of } from 'rxjs'; +import { from, of } from 'rxjs'; import { AuthFlowStrategy } from './auth-flow-strategy'; import { isTokenExpired } from '../utils'; From a9af1f9d2977621f1be929b755d7de32e73599a5 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Fri, 3 May 2024 14:53:13 +0300 Subject: [PATCH 3/3] remove unused service from handler --- .../src/lib/services/authentication-error-handler.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts b/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts index a3744f1ce7..44dab7e0a1 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts @@ -3,13 +3,11 @@ 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 {