diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-04-14 22:07:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-04-14 22:07:46 +0200 |
commit | 1553e15d82b8a1ec4967a90d43b33274f8215c44 (patch) | |
tree | ee53fdbb32895153a1fd2470e1c51cf1d9a38e77 /client/angular/users/components | |
parent | 0c1cbbfe29d91c95f9c574b57adf067654b8b5b4 (diff) | |
download | PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.gz PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.zst PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.zip |
Implement user requests autorizations in the client side
Diffstat (limited to 'client/angular/users/components')
-rw-r--r-- | client/angular/users/components/login/login.component.ts | 17 |
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 | ||
4 | import { AuthService } from '../../services/auth.service'; | 4 | import { AuthService } from '../../services/auth.service'; |
5 | import { AuthStatus } from '../../models/authStatus'; | 5 | import { AuthStatus } from '../../models/authStatus'; |
6 | import { Token } from '../../models/token'; | 6 | import { 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 | } |