feat(login): add login authentication and authorization (#122)
Add login basic authentication, oauth2 authentication, two factor authentication and authorization and allow to reset password on expiry. Fixes #117, #118, #119, #120
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
|
||||
import { finalize } from 'rxjs/operators';
|
||||
|
||||
import { Logger, AuthenticationService } from '../../core';
|
||||
|
||||
const log = new Logger('Login');
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-login-form',
|
||||
templateUrl: './login-form.component.html',
|
||||
styleUrls: ['./login-form.component.scss']
|
||||
})
|
||||
export class LoginFormComponent implements OnInit {
|
||||
|
||||
loginForm: FormGroup;
|
||||
passwordInputType: string;
|
||||
error: string;
|
||||
loading = false;
|
||||
authenticationEvent: any;
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private authenticationService: AuthenticationService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.createLoginForm();
|
||||
this.passwordInputType = 'password';
|
||||
}
|
||||
|
||||
public login() {
|
||||
this.loading = true;
|
||||
this.loginForm.disable();
|
||||
this.authenticationService.login(this.loginForm.value)
|
||||
.pipe(finalize(() => {
|
||||
this.loginForm.reset();
|
||||
this.loginForm.markAsPristine();
|
||||
// Bug: Validation errors won't get removed on reset
|
||||
this.loginForm.enable();
|
||||
this.loading = false;
|
||||
})).subscribe();
|
||||
}
|
||||
|
||||
public forgotPassword() {
|
||||
console.log('TODO: Forgot Password');
|
||||
}
|
||||
|
||||
private createLoginForm() {
|
||||
this.loginForm = this.formBuilder.group({
|
||||
'username': ['', Validators.required],
|
||||
'password': ['', Validators.required],
|
||||
'remember': false
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user