aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/users
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/users')
-rw-r--r--client/angular/users/services/auth.service.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/client/angular/users/services/auth.service.ts b/client/angular/users/services/auth.service.ts
index 89412c3df..c09f0a343 100644
--- a/client/angular/users/services/auth.service.ts
+++ b/client/angular/users/services/auth.service.ts
@@ -11,12 +11,29 @@ export class AuthService {
11 11
12 private _loginChanged; 12 private _loginChanged;
13 private _baseLoginUrl = '/api/v1/users/token'; 13 private _baseLoginUrl = '/api/v1/users/token';
14 private _baseClientUrl = '/api/v1/users/client';
14 private _clientId = '56f055587305d40b21904240'; 15 private _clientId = '56f055587305d40b21904240';
15 private _clientSecret = 'megustalabanana'; 16 private _clientSecret = 'megustalabanana';
16 17
17 constructor (private http: Http) { 18 constructor (private http: Http) {
18 this._loginChanged = new Subject<AuthStatus>(); 19 this._loginChanged = new Subject<AuthStatus>();
19 this.loginChanged$ = this._loginChanged.asObservable(); 20 this.loginChanged$ = this._loginChanged.asObservable();
21
22 // Fetch the client_id/client_secret
23 // FIXME: save in local storage?
24 this.http.get(this._baseClientUrl)
25 .map(res => res.json())
26 .catch(this.handleError)
27 .subscribe(
28 result => {
29 this._clientId = result.client_id;
30 this._clientSecret = result.client_secret;
31 console.log('Client credentials loaded.');
32 },
33 error => {
34 alert(error);
35 }
36 )
20 } 37 }
21 38
22 login(username: string, password: string) { 39 login(username: string, password: string) {