Correction pour soumettre le formulaire
avec la touche "Enter"
This commit is contained in:
@@ -39,7 +39,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
username: ['', [Validators.required, Validators.minLength(3)]],
|
||||
password: ['', [Validators.required]]
|
||||
},
|
||||
{ updateOn: 'blur' }
|
||||
{ updateOn: 'submit' }
|
||||
);
|
||||
|
||||
// get return url from route parameters or default to '/'
|
||||
@@ -54,21 +54,19 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
onLoginSubmit() {
|
||||
this.submitted = true;
|
||||
|
||||
if (this.loginForm.invalid) {
|
||||
return;
|
||||
if (this.loginForm.valid) {
|
||||
this.loading = true;
|
||||
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
},
|
||||
error => {
|
||||
this.error = error;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
},
|
||||
error => {
|
||||
this.error = error;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user