mercredi 4 novembre 2015

Redirect in Ember Router

I have a situation where we used to have a login page but now we use a separate oAuth page. I'm trying to clean out a bunch of code, but I need to worry about people who have bookmarked the login route. Ideally, I'd like to be able to do something like this:

Router.map(function () {

    this.route('login', {redirectTo: 'index'});
})

and then be able to get rid of the logic in my loginRoute:

var LoginRoute = Ember.Route.extend({

    beforeModel: function (transition) {

        var result = this._super(transition);

        if (transition.isActive === false) {
            // Route canceled for auth
            return result;
        } else {
            return this.transitionTo('index');
        }
    }
});

Is that possible or do I absolutely have to keep my login route?




Aucun commentaire:

Enregistrer un commentaire