Browse Source

add a getter that returns the active auth strategy

pull/7861/head
mehmet-erim 6 years ago
parent
commit
2a7d3555d5
  1. 8
      npm/ng-packs/packages/account/src/lib/services/authentication.service.ts
  2. 11
      npm/ng-packs/packages/core/src/lib/services/auth.service.ts

8
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<any> {
@ -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),
);

11
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();

Loading…
Cancel
Save