From e5b9efdf3285ad2f257d4cd2dea34f1c389b8c50 Mon Sep 17 00:00:00 2001 From: Chris Veilleux Date: Wed, 22 May 2019 20:53:24 -0500 Subject: [PATCH] fix an issue where you can't submit a password reset request if there is no password --- .../internal-login/internal-login.component.ts | 13 ++++++++++--- .../password-reset/password-reset.component.ts | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/projects/sso/src/app/modules/login/internal-login/internal-login.component.ts b/projects/sso/src/app/modules/login/internal-login/internal-login.component.ts index bcc7a3b..d773b02 100644 --- a/projects/sso/src/app/modules/login/internal-login/internal-login.component.ts +++ b/projects/sso/src/app/modules/login/internal-login/internal-login.component.ts @@ -17,6 +17,7 @@ export class InternalLoginComponent implements OnInit { public emailControl: AbstractControl; public loginForm: FormGroup; public passwordControl: AbstractControl; + public passwordResetForm: FormGroup; constructor( private authService: ApiService, @@ -36,6 +37,9 @@ export class InternalLoginComponent implements OnInit { }); this.emailControl = this.loginForm.controls['email']; this.passwordControl = this.loginForm.controls['password']; + this.passwordResetForm = this.formBuilder.group({ + email: [null, [Validators.email, Validators.required]], + }); } authorizeUser(): void { @@ -56,14 +60,17 @@ export class InternalLoginComponent implements OnInit { } onPasswordReset() { + this.passwordResetForm.controls['email'].setValue( + this.emailControl.value + ); const dialogRef = this.dialog.open( PasswordResetComponent, - {width: '320px', data: this.loginForm} + {width: '320px', data: this.passwordResetForm} ); dialogRef.afterClosed().subscribe( (result) => { if (result) { - this.loginForm.controls['email'].setValue(result); + this.passwordResetForm.setValue(result); this.resetPassword(); } } @@ -76,7 +83,7 @@ export class InternalLoginComponent implements OnInit { const snackbarConfig = new MatSnackBarConfig(); snackbarConfig.duration = fiveSeconds; 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(errorMessage, null, snackbarConfig); } ); diff --git a/projects/sso/src/app/modules/login/password-reset/password-reset.component.ts b/projects/sso/src/app/modules/login/password-reset/password-reset.component.ts index f4ef716..aadbff2 100644 --- a/projects/sso/src/app/modules/login/password-reset/password-reset.component.ts +++ b/projects/sso/src/app/modules/login/password-reset/password-reset.component.ts @@ -1,6 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; -import { FormGroup } from '@angular/forms'; +import { FormControl, FormGroup } from '@angular/forms'; @Component({ selector: 'sso-password-reset', @@ -11,7 +11,7 @@ export class PasswordResetComponent implements OnInit { constructor( public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public dialogData: FormGroup + @Inject(MAT_DIALOG_DATA) public dialogData: FormControl ) { } ngOnInit() {