From ba41ad27682a20effbf0d3816fe2373a0f53c18f Mon Sep 17 00:00:00 2001
From: Lukas Kimpel <lukas.kimpel@mni.thm.de>
Date: Tue, 6 Mar 2018 22:01:30 +0100
Subject: [PATCH] Update login logic Remove unnecassary redirect on login
 failed Add ngSubmit functionality to enable keyboard submit

---
 src/app/app.module.ts              | 2 +-
 src/app/login/login.component.html | 2 +-
 src/app/login/login.component.ts   | 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 3391ff636..f71216965 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 ac1a501a1..c5ee50f1d 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 d60ef87df..f2f44d6cf 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']);
         }
       });
     }
-- 
GitLab