From 192ea60b82806669fd633888fe9641f24bd5abd3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 4 Jun 2016 13:31:23 +0200 Subject: [PATCH] Improve the login form --- client/src/app/login/login.component.html | 24 +++++++++++++++++++---- client/src/app/login/login.component.ts | 8 ++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html index 940694515..5848fcba3 100644 --- a/client/src/app/login/login.component.html +++ b/client/src/app/login/login.component.html @@ -1,14 +1,30 @@

Login

-
+ + +
{{ error }}
+ +
- + +
+ Username is required +
- + +
+ Password is required +
- +
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 9d88536ca..768594ac4 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts @@ -9,6 +9,8 @@ import { AuthService, AuthStatus, User } from '../shared'; }) export class LoginComponent { + error: string = null; + constructor( private authService: AuthService, private router: Router @@ -17,6 +19,8 @@ export class LoginComponent { login(username: string, password: string) { this.authService.login(username, password).subscribe( result => { + this.error = null; + const user = new User(username, result); user.save(); @@ -26,9 +30,9 @@ export class LoginComponent { }, error => { if (error.error === 'invalid_grant') { - alert('Credentials are invalid.'); + this.error = 'Credentials are invalid.'; } else { - alert(`${error.error}: ${error.error_description}`); + this.error = `${error.error}: ${error.error_description}`; } } );