src/app/models/multifactor-model-response.model.ts
Properties |
Methods |
|
Accessors |
constructor(session?: Session)
|
||||||
Parameters :
|
Private isEmailValid |
isEmailValid()
|
Returns :
boolean
|
Private isPhoneNumbersValid |
isPhoneNumbersValid()
|
Returns :
boolean
|
allowsEmailMfa |
allowsEmailMfa:
|
Type : boolean
|
emailAddress |
emailAddress:
|
Type : string
|
hasGoogleAuth |
hasGoogleAuth:
|
Type : boolean
|
mfaType |
mfaType:
|
Type : string
|
Default value : MultiFactorTypes.Default
|
phoneNumbers |
phoneNumbers:
|
Type : Phone[]
|
secretType |
secretType:
|
Type : string
|
Default value : SecretTypes.Default
|
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
);
}
}