Merge pull request #3990 from vvlladd28/bug/reset-password-required-email

UI: Fixed email validation in form reset password
This commit is contained in:
Igor Kulikov 2021-01-25 17:15:31 +02:00 committed by GitHub
commit 072d0e49c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -28,7 +28,7 @@
<fieldset [disabled]="isLoading$ | async"> <fieldset [disabled]="isLoading$ | async">
<div tb-toast fxLayout="column" class="layout-padding"> <div tb-toast fxLayout="column" class="layout-padding">
<span style="height: 50px;"></span> <span style="height: 50px;"></span>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block" hideRequiredMarker>
<mat-label translate>login.email</mat-label> <mat-label translate>login.email</mat-label>
<input matInput type="email" autofocus formControlName="email" email required/> <input matInput type="email" autofocus formControlName="email" email required/>
<mat-icon class="material-icons" matPrefix>email</mat-icon> <mat-icon class="material-icons" matPrefix>email</mat-icon>

View File

@ -19,7 +19,7 @@ import { AuthService } from '@core/auth/auth.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { PageComponent } from '@shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { FormBuilder } from '@angular/forms'; import { FormBuilder, Validators } from '@angular/forms';
import { ActionNotificationShow } from '@core/notification/notification.actions'; import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -31,8 +31,8 @@ import { TranslateService } from '@ngx-translate/core';
export class ResetPasswordRequestComponent extends PageComponent implements OnInit { export class ResetPasswordRequestComponent extends PageComponent implements OnInit {
requestPasswordRequest = this.fb.group({ requestPasswordRequest = this.fb.group({
email: [''] email: ['', [Validators.email, Validators.required]]
}); }, {updateOn: 'submit'});
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
private authService: AuthService, private authService: AuthService,
@ -45,12 +45,16 @@ export class ResetPasswordRequestComponent extends PageComponent implements OnIn
} }
sendResetPasswordLink() { sendResetPasswordLink() {
this.authService.sendResetPasswordLink(this.requestPasswordRequest.get('email').value).subscribe( if (this.requestPasswordRequest.valid) {
() => { this.authService.sendResetPasswordLink(this.requestPasswordRequest.get('email').value).subscribe(
this.store.dispatch(new ActionNotificationShow({ message: this.translate.instant('login.password-link-sent-message'), () => {
type: 'success' })); this.store.dispatch(new ActionNotificationShow({
} message: this.translate.instant('login.password-link-sent-message'),
); type: 'success'
}));
}
);
}
} }
} }