aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/users/components
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/users/components')
-rw-r--r--client/angular/users/components/login/login.component.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/client/angular/users/components/login/login.component.ts b/client/angular/users/components/login/login.component.ts
index 0881a3a15..35dea4f9b 100644
--- a/client/angular/users/components/login/login.component.ts
+++ b/client/angular/users/components/login/login.component.ts
@@ -3,7 +3,7 @@ import { Router } from 'angular2/router';
3 3
4import { AuthService } from '../../services/auth.service'; 4import { AuthService } from '../../services/auth.service';
5import { AuthStatus } from '../../models/authStatus'; 5import { AuthStatus } from '../../models/authStatus';
6import { Token } from '../../models/token'; 6import { User } from '../../models/user';
7 7
8@Component({ 8@Component({
9 selector: 'my-user-login', 9 selector: 'my-user-login',
@@ -17,16 +17,21 @@ export class UserLoginComponent {
17 login(username: string, password: string) { 17 login(username: string, password: string) {
18 this._authService.login(username, password).subscribe( 18 this._authService.login(username, password).subscribe(
19 result => { 19 result => {
20 if (result.error) return alert(result.error_description); 20 const user = new User(username, result);
21 21 user.save();
22 let token = new Token(result);
23 token.save();
24 22
25 this._authService.setStatus(AuthStatus.LoggedIn); 23 this._authService.setStatus(AuthStatus.LoggedIn);
26 24
27 this._router.navigate(['VideosList']); 25 this._router.navigate(['VideosList']);
28 }, 26 },
29 error => alert(error) 27 error => {
28 if (error.error === 'invalid_grant') {
29 alert('Credentials are invalid.');
30 }
31 else {
32 alert(`${error.error}: ${error.error_description}`)
33 }
34 }
30 ); 35 );
31 } 36 }
32} 37}