Commit fdfd090b0bb844e08646dd75112a5a2227c71b11

Authored by Vladyslav_Prykhodko
1 parent 5caba218

UI: Fixed email validation in form reset password

@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 <fieldset [disabled]="isLoading$ | async"> 28 <fieldset [disabled]="isLoading$ | async">
29 <div tb-toast fxLayout="column" class="layout-padding"> 29 <div tb-toast fxLayout="column" class="layout-padding">
30 <span style="height: 50px;"></span> 30 <span style="height: 50px;"></span>
31 - <mat-form-field class="mat-block"> 31 + <mat-form-field class="mat-block" hideRequiredMarker>
32 <mat-label translate>login.email</mat-label> 32 <mat-label translate>login.email</mat-label>
33 <input matInput type="email" autofocus formControlName="email" email required/> 33 <input matInput type="email" autofocus formControlName="email" email required/>
34 <mat-icon class="material-icons" matPrefix>email</mat-icon> 34 <mat-icon class="material-icons" matPrefix>email</mat-icon>
@@ -19,7 +19,7 @@ import { AuthService } from '@core/auth/auth.service'; @@ -19,7 +19,7 @@ import { AuthService } from '@core/auth/auth.service';
19 import { Store } from '@ngrx/store'; 19 import { Store } from '@ngrx/store';
20 import { AppState } from '@core/core.state'; 20 import { AppState } from '@core/core.state';
21 import { PageComponent } from '@shared/components/page.component'; 21 import { PageComponent } from '@shared/components/page.component';
22 -import { FormBuilder } from '@angular/forms'; 22 +import { FormBuilder, Validators } from '@angular/forms';
23 import { ActionNotificationShow } from '@core/notification/notification.actions'; 23 import { ActionNotificationShow } from '@core/notification/notification.actions';
24 import { TranslateService } from '@ngx-translate/core'; 24 import { TranslateService } from '@ngx-translate/core';
25 25
@@ -31,8 +31,8 @@ import { TranslateService } from '@ngx-translate/core'; @@ -31,8 +31,8 @@ import { TranslateService } from '@ngx-translate/core';
31 export class ResetPasswordRequestComponent extends PageComponent implements OnInit { 31 export class ResetPasswordRequestComponent extends PageComponent implements OnInit {
32 32
33 requestPasswordRequest = this.fb.group({ 33 requestPasswordRequest = this.fb.group({
34 - email: ['']  
35 - }); 34 + email: ['', [Validators.email, Validators.required]]
  35 + }, {updateOn: 'submit'});
36 36
37 constructor(protected store: Store<AppState>, 37 constructor(protected store: Store<AppState>,
38 private authService: AuthService, 38 private authService: AuthService,
@@ -45,12 +45,16 @@ export class ResetPasswordRequestComponent extends PageComponent implements OnIn @@ -45,12 +45,16 @@ export class ResetPasswordRequestComponent extends PageComponent implements OnIn
45 } 45 }
46 46
47 sendResetPasswordLink() { 47 sendResetPasswordLink() {
48 - this.authService.sendResetPasswordLink(this.requestPasswordRequest.get('email').value).subscribe(  
49 - () => {  
50 - this.store.dispatch(new ActionNotificationShow({ message: this.translate.instant('login.password-link-sent-message'),  
51 - type: 'success' }));  
52 - }  
53 - ); 48 + if (this.requestPasswordRequest.valid) {
  49 + this.authService.sendResetPasswordLink(this.requestPasswordRequest.get('email').value).subscribe(
  50 + () => {
  51 + this.store.dispatch(new ActionNotificationShow({
  52 + message: this.translate.instant('login.password-link-sent-message'),
  53 + type: 'success'
  54 + }));
  55 + }
  56 + );
  57 + }
54 } 58 }
55 59
56 } 60 }