All files / src/app/shared/components/login/identity-provider-login identity-provider-login.component.ts

31.25% Statements 5/16
50% Branches 3/6
0% Functions 0/2
31.25% Lines 5/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 523x                   3x 3x 3x             3x                                                                
import {
  ChangeDetectionStrategy,
  Component,
  ComponentRef,
  Input,
  OnInit,
  ViewChild,
  ViewContainerRef,
} from '@angular/core';
 
import { IdentityProviderFactory } from 'ish-core/identity-provider/identity-provider.factory';
import { Auth0SignInComponent } from 'ish-shared/components/login/auth0-sign-in/auth0-sign-in.component';
import { LoginFormComponent } from 'ish-shared/components/login/login-form/login-form.component';
 
@Component({
  selector: 'ish-identity-provider-login',
  templateUrl: './identity-provider-login.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IdentityProviderLoginComponent implements OnInit {
  @Input() labelClass: string;
  @Input() inputClass: string;
  @Input() forgotPasswordClass: string;
  @Input() signInClass: string;
 
  @ViewChild('anchor', { read: ViewContainerRef, static: true }) anchor: ViewContainerRef;
 
  constructor(private identityProviderFactory: IdentityProviderFactory) {}
 
  ngOnInit() {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    let componentRef: ComponentRef<any>;
 
    switch (this.identityProviderFactory.getType()) {
      case 'auth0':
        componentRef = this.anchor.createComponent(Auth0SignInComponent);
        break;
 
      default:
        componentRef = this.anchor.createComponent(LoginFormComponent);
        break;
    }
 
    componentRef.instance.labelClass = this.labelClass;
    componentRef.instance.inputClass = this.inputClass;
    componentRef.instance.forgotPasswordClass = this.forgotPasswordClass;
    componentRef.instance.signInClass = this.signInClass;
 
    componentRef.changeDetectorRef.markForCheck();
  }
}