Skip to content

Commit e6b6b2c

Browse files
committed
Email is required to request password reset
1 parent 36500fc commit e6b6b2c

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

client/app/user/components/request-password-reset/request-password-reset.component.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {
2+
deliverableEmail,
23
ifValid,
34
NaturalAlertService,
45
NaturalErrorMessagePipe,
56
NaturalIconDirective,
67
validateAllFormControls,
78
} from '@ecodev/natural';
89
import {Component, inject} from '@angular/core';
9-
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
10+
import {FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from '@angular/forms';
1011
import {Router} from '@angular/router';
1112
import {UserService} from '../../../admin/users/services/user.service';
1213
import {MatButton} from '@angular/material/button';
@@ -36,22 +37,19 @@ export class RequestPasswordResetComponent {
3637
private readonly alertService = inject(NaturalAlertService);
3738
private readonly router = inject(Router);
3839
private readonly userService = inject(UserService);
40+
private readonly fb = inject(NonNullableFormBuilder);
3941

40-
protected readonly form: FormGroup;
42+
protected readonly form = this.fb.group({
43+
email: ['', [Validators.required, deliverableEmail, Validators.maxLength(191)]],
44+
});
4145
protected sending = false;
4246

43-
public constructor() {
44-
const userService = this.userService;
45-
46-
this.form = new FormGroup({email: new FormControl('', userService.getFormValidators().email)});
47-
}
48-
4947
protected submit(): void {
5048
validateAllFormControls(this.form);
5149
ifValid(this.form).subscribe(() => {
5250
this.sending = true;
5351

54-
this.userService.requestPasswordReset(this.form.value.email).subscribe({
52+
this.userService.requestPasswordReset(this.form.getRawValue().email).subscribe({
5553
next: () => {
5654
this.sending = false;
5755

0 commit comments

Comments
 (0)