diff --git a/app/routes/application.js b/app/routes/application.js index f43b37d2..02b70a72 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -9,8 +9,13 @@ export default TravisRoute.extend(BuildFaviconMixin, { this._super.apply(this, arguments); return this.get('auth').refreshUserData().then( () => { this.setupPendo(); - }, () => { - return this.get('auth').signOut(); + }, (xhr) => { + // 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(); + } }); }, diff --git a/app/services/auth.js b/app/services/auth.js index 0487cfef..fa74fb06 100644 --- a/app/services/auth.js +++ b/app/services/auth.js @@ -140,7 +140,7 @@ export default Ember.Service.extend({ data.user.token = user.token; this.storeData(data, this.get('sessionStorage')); this.storeData(data, this.get('storage')); - return Travis.trigger('user:refreshed', data.user); + Travis.trigger('user:refreshed', data.user); } } else { return Ember.RSVP.Promise.reject();