File

src/app/models/multifactor-model-response.model.ts

Index

Properties
Methods
Accessors

Constructor

constructor(session?: Session)
Parameters :
Name Type Optional
session Session yes

Methods

Private isEmailValid
isEmailValid()
Returns : boolean
Private isPhoneNumbersValid
isPhoneNumbersValid()
Returns : boolean

Properties

allowsEmailMfa
allowsEmailMfa: boolean
Type : boolean
emailAddress
emailAddress: string
Type : string
hasGoogleAuth
hasGoogleAuth: boolean
Type : boolean
mfaType
mfaType: string
Type : string
Default value : MultiFactorTypes.Default
phoneNumbers
phoneNumbers: Phone[]
Type : Phone[]
secretType
secretType: string
Type : string
Default value : SecretTypes.Default

Accessors

isValid
getisValid()
import { Phone } from './phone.model';
import { MultiFactorTypes } from '../enums/multi-factor-types';
import { SecretTypes } from '../enums/secret-types';
import { Session } from '.';

export class MultiFactorModel {
  emailAddress: string;
  phoneNumbers: Phone[];
  hasGoogleAuth: boolean;
  allowsEmailMfa: boolean;
  mfaType: string = MultiFactorTypes.Default;
  secretType: string = SecretTypes.Default;

  constructor(session?: Session) {
    if (!session) {
      return;
    }

    this.emailAddress = session.email ? session.email : null;
    this.phoneNumbers = session.phones ? session.phones : null;
    this.hasGoogleAuth = session.hasGoogleAuth ? session.hasGoogleAuth : null;
    this.allowsEmailMfa = session.allowsEmailMfa != undefined ? session.allowsEmailMfa : true;

    this.mfaType = session.mfaType ? session.mfaType : null;
    this.secretType = session.secretType ? session.secretType : null;
  }

  get isValid(): boolean {
    return this.isEmailValid() || this.isPhoneNumbersValid();
  }

  private isEmailValid(): boolean {
    return this.emailAddress !== undefined && this.emailAddress !== null && this.emailAddress.length > 0;
  }

  private isPhoneNumbersValid(): boolean {
    return (
      this.phoneNumbers !== undefined &&
      this.phoneNumbers !== null &&
      this.phoneNumbers.length > 0 &&
      this.phoneNumbers[0].number !== undefined &&
      this.phoneNumbers[0].number !== null &&
      this.phoneNumbers[0].number.length > 0
    );
  }
}

results matching ""

    No results matching ""