Log user out only if necessary on failed user data request
This commit is contained in:
parent
fa7c275eaa
commit
c6ec02429d
|
@ -9,8 +9,13 @@ export default TravisRoute.extend(BuildFaviconMixin, {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
return this.get('auth').refreshUserData().then( () => {
|
return this.get('auth').refreshUserData().then( () => {
|
||||||
this.setupPendo();
|
this.setupPendo();
|
||||||
}, () => {
|
}, (xhr) => {
|
||||||
return this.get('auth').signOut();
|
// if xhr is not defined it means that scopes are not correct,
|
||||||
|
// so log the user out. Also log the user out if the response is 401
|
||||||
|
// or 403
|
||||||
|
if(!xhr || (xhr.status === 401 || xhr.status === 403)) {
|
||||||
|
return this.get('auth').signOut();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ export default Ember.Service.extend({
|
||||||
data.user.token = user.token;
|
data.user.token = user.token;
|
||||||
this.storeData(data, this.get('sessionStorage'));
|
this.storeData(data, this.get('sessionStorage'));
|
||||||
this.storeData(data, this.get('storage'));
|
this.storeData(data, this.get('storage'));
|
||||||
return Travis.trigger('user:refreshed', data.user);
|
Travis.trigger('user:refreshed', data.user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Ember.RSVP.Promise.reject();
|
return Ember.RSVP.Promise.reject();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user