diff --git a/npm/ng-packs/packages/account/src/lib/services/authentication.service.ts b/npm/ng-packs/packages/account/src/lib/services/authentication.service.ts index 2cd303f373..ff5dd926e7 100644 --- a/npm/ng-packs/packages/account/src/lib/services/authentication.service.ts +++ b/npm/ng-packs/packages/account/src/lib/services/authentication.service.ts @@ -1,6 +1,8 @@ import { Inject, Injectable, Optional } from '@angular/core'; import { AbpApplicationConfigurationService, + AuthPasswordFlowStrategy, + AuthService, ConfigStateService, RestService, SessionStateService, @@ -13,19 +15,18 @@ import { ACCOUNT_OPTIONS } from '../tokens/options.token'; import { Options } from '../models/options'; import snq from 'snq'; import { Router } from '@angular/router'; -import { SessionHandler } from '@abp/ng.account/config'; @Injectable() export class AuthenticationService { constructor( protected rest: RestService, protected sessionState: SessionStateService, + protected authService: AuthService, protected oAuthService: OAuthService, protected appConfigService: AbpApplicationConfigurationService, protected configState: ConfigStateService, @Inject(ACCOUNT_OPTIONS) protected options: Options, protected router: Router, - @Optional() protected sessionHandler: SessionHandler, ) {} login(username: string, password: string, remember = false): Observable { @@ -47,7 +48,8 @@ export class AuthenticationService { this.router.navigate([redirectUrl]); - if (this.sessionHandler) this.sessionHandler.setRememberInfo(remember); + const strategy = this.authService.activeAuthFlowStrategy; + if (strategy instanceof AuthPasswordFlowStrategy) strategy.setRememberMe(remember); }), take(1), ); 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 fbd2206fd8..47ccc01184 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 @@ -1,6 +1,11 @@ import { Injectable, Injector } from '@angular/core'; import { Observable } from 'rxjs'; -import { AuthFlowStrategy, AUTH_FLOW_STRATEGY } from '../strategies/auth-flow.strategy'; +import { + AuthCodeFlowStrategy, + AuthFlowStrategy, + AuthPasswordFlowStrategy, + AUTH_FLOW_STRATEGY, +} from '../strategies/auth-flow.strategy'; import { EnvironmentService } from './environment.service'; @Injectable({ @@ -14,6 +19,10 @@ export class AuthService { return this.strategy.isInternalAuth; } + get activeAuthFlowStrategy() { + return this.strategy as AuthCodeFlowStrategy | AuthPasswordFlowStrategy; + } + constructor(private environment: EnvironmentService, private injector: Injector) { this.setStrategy(); this.listenToSetEnvironment();