Fix race condition in login
This commit is contained in:
parent
b1c2f531bb
commit
7d637e84e4
1 changed files with 16 additions and 14 deletions
|
@ -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() {
|
||||||
|
|
Reference in a new issue