简体   繁体   中英

AuthenticatedRouteMixin: No redirection when route hooks are overridden

Authentication seems to be skipped if I define beforeModel hook in my index route. Maybe this overrides the mixin's beforeModel...

Example: the following does not redirect me to /login until I remove 'beforeModel' from my route. The same for 'afterModel' and possibly other hooks

// app/routes/index.js
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin,{
 beforeModel : function(){
    // empty function
  }
});

any help would be appreciated. What I want to do is simple transitions from route to route. Eg. go to /users/userlist when the URL is simple /users

This overrides the mixin's implementation as you already suggested. You need to call this._super(transition); :

beforeModel: function(transition, queryParams) {
  this._super(transition, queryParams);
  …
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM