Skip to content
Snippets Groups Projects
Verified Commit ba41ad27 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Update login logic

Remove unnecassary redirect on login failed
Add ngSubmit functionality to enable keyboard submit
parent d3b1ed75
Branches
Tags
No related merge requests found
......@@ -107,7 +107,7 @@ import { AuthenticationGuard } from './authentication.guard';
providers: [
NotificationService,
AuthenticationService,
AuthenticationGuard,
AuthenticationGuard
],
bootstrap: [AppComponent]
})
......
<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>
......
......@@ -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']);
}
});
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment