diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3391ff6366dba78f11937dd2c24d4fcd1f00531c..f712169653107d5b3cea21d62043e17d18d9297f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -107,7 +107,7 @@ import { AuthenticationGuard } from './authentication.guard'; providers: [ NotificationService, AuthenticationService, - AuthenticationGuard, + AuthenticationGuard ], bootstrap: [AppComponent] }) diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index ac1a501a15acb44d02d9a9d7acbe3e216075b384..c5ee50f1d4c1a56e43c651915a30a044983452b0 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -1,4 +1,4 @@ -<form> +<form (ngSubmit)="login(userName.value, userPassword.value)"> <mat-form-field class="input-block"> <input matInput #userName placeholder="Username" [formControl]="usernameFormControl" [errorStateMatcher]="matcher" name="username" /> <mat-error *ngIf="usernameFormControl.hasError('required')">Username is <strong>required</strong>.</mat-error> diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index d60ef87dfa81d6cf506f19270f17e1688e47d523..f2f44d6cf31cd4d787575b61bbfebe1735ce39ad 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -8,7 +8,7 @@ import { FormControl, FormGroupDirective, NgForm, ReactiveFormsModule, Validator export class LoginErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { const isSubmitted = form && form.submitted; - return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted)); + return (control && control.invalid && (control.dirty || control.touched || isSubmitted)); } } @@ -43,7 +43,6 @@ export class LoginComponent implements OnInit { this.router.navigate(['rooms']); } else { this.notificationService.show('Login failed!'); - this.router.navigate(['home']); } }); }