diff --git a/npm/ng-packs/packages/core/src/lib/services/auth.service.ts b/npm/ng-packs/packages/core/src/lib/services/auth.service.ts index 752721e41a..3a1dadc4cb 100644 --- a/npm/ng-packs/packages/core/src/lib/services/auth.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/auth.service.ts @@ -41,8 +41,8 @@ export class AuthService { .toPromise(); } - logout(): Observable { - return this.strategy.logout(); + logout(queryParams?: Params): Observable { + return this.strategy.logout(queryParams); } /** diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index 1d79311f9c..eae95c6a4d 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -38,10 +38,10 @@ export abstract class AuthFlowStrategy { protected sessionState: SessionStateService; protected appConfigService: AbpApplicationConfigurationService; - abstract checkIfInternalAuth(): boolean; + abstract checkIfInternalAuth(queryParams?: Params): boolean; abstract navigateToLogin(queryParams?: Params): void; - abstract logout(): Observable; - abstract login(params?: LoginParams): Observable; + abstract logout(queryParams?: Params): Observable; + abstract login(params?: LoginParams | Params): Observable; private catchError = err => this.store.dispatch(new RestOccurError(err)); @@ -105,24 +105,28 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy { } navigateToLogin(queryParams?: Params) { - const lang = this.sessionState.getLanguage(); - const culture = { culture: lang, 'ui-culture': lang }; - this.oAuthService.initCodeFlow(null, { ...(lang && culture), ...queryParams }); + this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams)); } - checkIfInternalAuth() { - this.oAuthService.initCodeFlow(); + checkIfInternalAuth(queryParams?: Params) { + this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams)); return false; } - logout() { - return from(this.oAuthService.revokeTokenAndLogout()); + logout(queryParams?: Params) { + return from(this.oAuthService.revokeTokenAndLogout(this.getCultureParams(queryParams))); } - login() { - this.oAuthService.initCodeFlow(); + login(queryParams?: Params) { + this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams)); return of(null); } + + private getCultureParams(queryParams?: Params) { + const lang = this.sessionState.getLanguage(); + const culture = { culture: lang, 'ui-culture': lang }; + return { ...(lang && culture), ...queryParams }; + } } export class AuthPasswordFlowStrategy extends AuthFlowStrategy { @@ -203,10 +207,10 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { ); } - logout() { + logout(queryParams?: Params) { const router = this.injector.get(Router); - return from(this.oAuthService.revokeTokenAndLogout()).pipe( + return from(this.oAuthService.revokeTokenAndLogout(queryParams)).pipe( switchMap(() => this.appConfigService.get()), tap(res => { this.configState.setState(res);