/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; /** rxjs Imports */ import { finalize } from 'rxjs/operators' ; /** Custom Services */ import { AuthenticationService } from '../../core/authentication/authentication.service' ; /**
 * Login form component.
 */ @ Component ( { selector : 'mifosx-login-form' , templateUrl : './login-form.component.html' , styleUrls : [ './login-form.component.scss' ] } ) export class LoginFormComponent implements OnInit { /** Login form group. */ loginForm : FormGroup ; /** Password input field type. */ passwordInputType : string ; /** True if loading. */ loading = false ; param { FormBuilder } formBuilder param { AuthenticationService } authenticationService constructor ( private formBuilder , private authenticationService ) { } /**
     * Creates login form.
     *
     * Initializes password input field type.
     */ ngOnInit ( ) { this . createLoginForm ( ) ; this . passwordInputType = 'password' ; } /**
     * Authenticates the user if the credentials are valid.
     */ login ( ) { this . loading = true ; this . loginForm . disable ( ) ; this . authenticationService . login ( this . loginForm . value ) . pipe ( finalize ( ( ) => { this . loginForm . reset ( ) ; this . loginForm . markAsPristine ( ) ; this . loginForm . enable ( ) ; this . loading = false ; } ) ) . subscribe ( ) ; } /**
     * TODO: Decision to be taken on providing this feature.
     */ forgotPassword ( ) { console . log ( 'Forgot Password feature currently unavailable.' ) ; } /**
     * Creates login form.
     */ private createLoginForm ( ) { this . loginForm = this . formBuilder . group ( { 'username' : [ '' , Validators . required ] , 'password' : [ '' , Validators . required ] , 'remember' : false } ) ; } }