Browse Source

pass `noRedirectToLogoutUrl` parameter to logout method

pull/19702/head
Sinan997 2 years ago
parent
commit
e46ba45867
  1. 6
      npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts
  2. 4
      npm/ng-packs/packages/theme-shared/src/lib/services/authentication-error-handler.service.ts

6
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)));
}

4
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 });
}
});
}

Loading…
Cancel
Save