From 23a5a916dba8960e77e0dcc9f9050e0df0a5f60b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Apr 2016 22:11:48 +0200 Subject: Make angular client load dynamically the generated client id/secret --- client/angular/users/services/auth.service.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'client/angular/users/services/auth.service.ts') 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 { private _loginChanged; private _baseLoginUrl = '/api/v1/users/token'; + private _baseClientUrl = '/api/v1/users/client'; private _clientId = '56f055587305d40b21904240'; private _clientSecret = 'megustalabanana'; constructor (private http: Http) { this._loginChanged = new Subject(); this.loginChanged$ = this._loginChanged.asObservable(); + + // Fetch the client_id/client_secret + // FIXME: save in local storage? + this.http.get(this._baseClientUrl) + .map(res => res.json()) + .catch(this.handleError) + .subscribe( + result => { + this._clientId = result.client_id; + this._clientSecret = result.client_secret; + console.log('Client credentials loaded.'); + }, + error => { + alert(error); + } + ) } login(username: string, password: string) { -- cgit v1.2.3