Merge remote-tracking branch 'remotes/origin/dev' into test

pull/8/head
Chris Veilleux 2019-05-22 20:53:44 -05:00
commit 2fdc50b50c
2 changed files with 12 additions and 5 deletions

View File

@ -17,6 +17,7 @@ export class InternalLoginComponent implements OnInit {
public emailControl: AbstractControl; public emailControl: AbstractControl;
public loginForm: FormGroup; public loginForm: FormGroup;
public passwordControl: AbstractControl; public passwordControl: AbstractControl;
public passwordResetForm: FormGroup;
constructor( constructor(
private authService: ApiService, private authService: ApiService,
@ -36,6 +37,9 @@ export class InternalLoginComponent implements OnInit {
}); });
this.emailControl = this.loginForm.controls['email']; this.emailControl = this.loginForm.controls['email'];
this.passwordControl = this.loginForm.controls['password']; this.passwordControl = this.loginForm.controls['password'];
this.passwordResetForm = this.formBuilder.group({
email: [null, [Validators.email, Validators.required]],
});
} }
authorizeUser(): void { authorizeUser(): void {
@ -56,14 +60,17 @@ export class InternalLoginComponent implements OnInit {
} }
onPasswordReset() { onPasswordReset() {
this.passwordResetForm.controls['email'].setValue(
this.emailControl.value
);
const dialogRef = this.dialog.open( const dialogRef = this.dialog.open(
PasswordResetComponent, PasswordResetComponent,
{width: '320px', data: this.loginForm} {width: '320px', data: this.passwordResetForm}
); );
dialogRef.afterClosed().subscribe( dialogRef.afterClosed().subscribe(
(result) => { (result) => {
if (result) { if (result) {
this.loginForm.controls['email'].setValue(result); this.passwordResetForm.setValue(result);
this.resetPassword(); this.resetPassword();
} }
} }
@ -76,7 +83,7 @@ export class InternalLoginComponent implements OnInit {
const snackbarConfig = new MatSnackBarConfig(); const snackbarConfig = new MatSnackBarConfig();
snackbarConfig.duration = fiveSeconds; snackbarConfig.duration = fiveSeconds;
snackbarConfig.panelClass = 'mycroft-no-action-snackbar'; snackbarConfig.panelClass = 'mycroft-no-action-snackbar';
this.authService.resetPassword(this.loginForm.controls['email']).subscribe( this.authService.resetPassword(this.passwordResetForm.controls['email']).subscribe(
() => { this.snackBar.open(successMessage, null, snackbarConfig); }, () => { this.snackBar.open(successMessage, null, snackbarConfig); },
() => { this.snackBar.open(errorMessage, null, snackbarConfig); } () => { this.snackBar.open(errorMessage, null, snackbarConfig); }
); );

View File

@ -1,6 +1,6 @@
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { FormGroup } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
@Component({ @Component({
selector: 'sso-password-reset', selector: 'sso-password-reset',
@ -11,7 +11,7 @@ export class PasswordResetComponent implements OnInit {
constructor( constructor(
public dialogRef: MatDialogRef<PasswordResetComponent>, public dialogRef: MatDialogRef<PasswordResetComponent>,
@Inject(MAT_DIALOG_DATA) public dialogData: FormGroup @Inject(MAT_DIALOG_DATA) public dialogData: FormControl
) { } ) { }
ngOnInit() { ngOnInit() {