refactor: improve code quality

pull/4995/head
mehmet-erim 5 years ago
parent ede9dc9b8c
commit da1c0ad793

@ -1,7 +1,7 @@
import { HttpHeaders } from '@angular/common/http';
import { Inject, Injectable, Injector, Optional } from '@angular/core';
import { Navigate } from '@ngxs/router-plugin';
import { Store, Actions, ofActionSuccessful } from '@ngxs/store';
import { Actions, ofActionSuccessful, Store } from '@ngxs/store';
import { OAuthService } from 'angular-oauth2-oidc';
import { from, Observable } from 'rxjs';
import { switchMap, take, tap } from 'rxjs/operators';
@ -9,19 +9,15 @@ import snq from 'snq';
import { GetAppConfiguration, SetEnvironment } from '../actions/config.actions';
import { ConfigState } from '../states/config.state';
import { SessionState } from '../states/session.state';
import { AuthFlowStrategy, AUTH_FLOW_STRATEGY } from '../strategies/auth-flow.strategy';
import { RestService } from './rest.service';
import {
AuthCodeFlowStrategy,
AuthPasswordFlowStrategy,
AUTH_FLOW_STRATEGY,
} from '../strategies/auth-flow.strategy';
@Injectable({
providedIn: 'root',
})
export class AuthService {
private flow: string;
private strategy: AuthCodeFlowStrategy | AuthPasswordFlowStrategy;
private strategy: AuthFlowStrategy;
get isInternalAuth() {
return this.strategy.isInternalAuth;

@ -10,10 +10,7 @@ import { switchMap } from 'rxjs/operators';
import { GetAppConfiguration } from '../actions/config.actions';
export abstract class AuthFlowStrategy {
protected abstract _isInternalAuth: boolean;
get isInternalAuth(): boolean {
return this._isInternalAuth;
}
abstract readonly isInternalAuth: boolean;
protected oAuthService: OAuthService;
protected oAuthConfig: AuthConfig;
@ -38,7 +35,7 @@ export abstract class AuthFlowStrategy {
}
export class AuthCodeFlowStrategy extends AuthFlowStrategy {
protected _isInternalAuth = false;
readonly isInternalAuth = false;
async init() {
return super
@ -65,7 +62,7 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
}
export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
protected _isInternalAuth = true;
readonly isInternalAuth = true;
login() {
const router = this.injector.get(Router);

Loading…
Cancel
Save