Fix race condition in login

This commit is contained in:
Tom Bloor 2017-09-08 14:59:31 +01:00
parent b1c2f531bb
commit 7d637e84e4

View file

@ -55,21 +55,23 @@ export class ApiService {
} }
public login(data) { public login(data) {
const login_event = this.http.post( return this.http
this.apiUrl + '/login', .post(
data this.apiUrl + '/login',
).map( response => response.json() ); data
login_event.subscribe( )
result => { .map(
this.setSessionKey(result.session_key); result => {
this.setUserInfo( const json = result.json();
result.email, this.setSessionKey(json.session_key);
result.display_name || result.name this.setUserInfo(
json.email,
json.display_name || json.name
); );
this.setUserType(result.user_type); this.setUserType(json.user_type);
} return json;
); }
return login_event; );
} }
public logout() { public logout() {