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) {
|
||||
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() {
|
||||
|
|
Reference in a new issue