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) {
const login_event = this.http.post(
return this.http
.post(
this.apiUrl + '/login',
data
).map( response => response.json() );
login_event.subscribe(
)
.map(
result => {
this.setSessionKey(result.session_key);
const json = result.json();
this.setSessionKey(json.session_key);
this.setUserInfo(
result.email,
result.display_name || result.name
json.email,
json.display_name || json.name
);
this.setUserType(result.user_type);
this.setUserType(json.user_type);
return json;
}
);
return login_event;
}
public logout() {