1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Make angular client load dynamically the generated client id/secret

This commit is contained in:
Chocobozzz 2016-04-27 22:11:48 +02:00
parent 2693922352
commit 23a5a916db
3 changed files with 46 additions and 0 deletions

View file

@ -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<AuthStatus>();
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) {