File
Implements
Metadata
selector |
app-authenticate-method |
styleUrls |
authenticate-method.component.css |
templateUrl |
./authenticate-method.component.html |
Index
Properties
|
|
Methods
|
|
Outputs
|
|
Methods
modelIsDefined
|
modelIsDefined()
|
|
|
stopPropagation
|
stopPropagation(event: Event)
|
|
Parameters :
Name |
Type |
Optional |
event |
Event
|
no
|
|
toggleAuthInput
|
toggleAuthInput(event: Event)
|
|
Parameters :
Name |
Type |
Optional |
event |
Event
|
no
|
|
toggleAuthMethod
|
toggleAuthMethod(event: Event)
|
|
Parameters :
Name |
Type |
Optional |
event |
Event
|
no
|
|
isLoading
|
isLoading:
|
Default value : false
|
|
loadingHeader
|
loadingHeader: string
|
Type : string
|
Default value : 'Retrieving Data'
|
|
loadingMessage
|
loadingMessage: string
|
Type : string
|
Default value : 'Please wait a moment while we retrieve your information.'
|
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
import { MultiFactorModel, SelectedMultiFactorMethod } from '../models';
import { MultiFactorService } from '../services';
import { ErrorStore } from '../stores';
import { AppState } from '../stores/app-state.store';
@Component({
selector: 'app-authenticate-method',
templateUrl: './authenticate-method.component.html',
styleUrls: ['./authenticate-method.component.css'],
})
export class AuthenticateMethodComponent implements OnInit {
@Output()
closeAuthMethod = new EventEmitter();
@Output()
openAuthInput = new EventEmitter();
isLoading = false;
model: MultiFactorModel;
loadingHeader = 'Retrieving Data';
loadingMessage = 'Please wait a moment while we retrieve your information.';
constructor(
public app: AppState,
private multiFactorService: MultiFactorService,
private router: Router,
private errorService: ErrorStore
) {}
modelIsDefined() {
return this.model !== null && this.model !== undefined;
}
ngOnInit() {
this.isLoading = true;
this.multiFactorService.getMethods().subscribe((model) => {
// When model isn't cached on app load *ngIf to toggle view doesn't fire correctly.
// Todo determine why and fix. Otherwise leave workaround (preload data in app component)
this.app.multiFactorModel = model;
this.model = model;
if (model === null || model === undefined || !model.isValid) {
this.errorService.addError(
'You are missing the necessary contact information to use this feature.',
'Please contact your financial institution.'
);
this.errorService.displayErrors();
}
if (!model.allowsEmailMfa && (!model.phoneNumbers || model.phoneNumbers.length === 0)) {
this.errorService.addError(
'You are missing a Phone Number to use this feature.',
'Please contact your financial institution.'
);
this.errorService.displayErrors();
}
this.isLoading = false;
});
}
select(method: string, target: string) {
this.loadingHeader = 'Sending Code';
this.loadingMessage = 'Please wait a moment while we are sending a code to you.';
this.isLoading = true;
this.multiFactorService.requestCode(method, target).subscribe((wasSent) => {
if (!wasSent) {
this.errorService.addError(
'Error',
'An unexpected error occurred. Please try again. Otherwise, please contact your financial insitution.'
);
return this.errorService.displayErrors();
}
this.app.selectedMethod = new SelectedMultiFactorMethod(method, target);
this.isLoading = false;
if (!this.app.useMfaModal) {
this.router.navigate(['/authenticate-input']);
} else {
this.toggleAuthInput(event);
}
});
}
toggleAuthMethod(event: Event) {
this.closeAuthMethod.emit();
this.app.useMfaModal = false;
}
toggleAuthInput(event: Event) {
this.closeAuthMethod.emit();
this.openAuthInput.emit();
}
stopPropagation(event: Event) {
event.stopPropagation();
}
}
<div [ngClass]="{ overlay: app.useMfaModal }" class="scroller" (click)="toggleAuthMethod($event)">
<div class="pop-up" id="authenticateUserMethod" (click)="stopPropagation($event)">
<div class="close-ctn">
<a id="closeButton" (click)="toggleAuthMethod($event)">
<i class="material-icons">close</i>
</a>
</div>
<h1 id="authUserHeader" class="page-headers" [hidden]="isLoading && !app.useMfaModal">
Authenticate User
</h1>
<div class="pop-up-ctn-body">
<div *ngIf="!isLoading && modelIsDefined()">
<div class="page-description">
<p class="para-medium">
Select a method below to determine how you will receive the authentication code.
</p>
</div>
<div class="auth-actions-ctn">
<!-- Send By Email -->
<div
*ngIf="model.allowsEmailMfa"
id="authSelectEmail"
class="auth-send-row"
(click)="select('EMAIL', model.emailAddress)"
>
<div class="auth-send-row-inner">
<div class="auth-send-label">
<p class="auth-send-method">Send authentication code by email</p>
<p class="method-output">{{ model.emailAddress }}</p>
</div>
</div>
</div>
<!-- Send By Text -->
<div id="authSelectSms">
<div *ngFor="let phone of model.phoneNumbers">
<div (click)="select('SMS', phone.number)" class="auth-send-row" *ngIf="phone.isTextCapable">
<div class="auth-send-row-inner">
<div class="auth-send-label">
<p class="auth-send-method">Send authentication code by text</p>
<p class="method-output">{{ phone.maskedNumber }}</p>
</div>
</div>
</div>
</div>
</div>
<!-- Send By Voice -->
<div id="authSelectVoice">
<div *ngFor="let phone of model.phoneNumbers">
<div (click)="select('VOICE', phone.number)" class="auth-send-row">
<div class="auth-send-row-inner">
<div class="auth-send-label">
<p class="auth-send-method">Send authentication code by phone call</p>
<p class="method-output">{{ phone.maskedNumber }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div *ngIf="isLoading" class="loading-ctn">
<app-loader [header]="loadingHeader" [message]="loadingMessage"></app-loader>
</div>
</div>
</div>
</div>
Legend
Html element with directive