samedi 14 octobre 2017

Handling a 403 in Ember.js

I'd like to redirect a user to /login if they receive a 403 from my API. Here is what I have in my /app/routes/application.js:

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth-auth0/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {
  actions: {
    error(error, transition) {
      if (error.status === '403') {
        this.replaceWith('login');
      } else {
        return true;
      }
    }
  }
});

But this doesn't seem to work nicely with Ember Data, and when a 403 is returned, the exception is raised, but not handled by the router, any tips?




Aucun commentaire:

Enregistrer un commentaire