0

目前我面临的问题是我需要在我自己的一个控制器中使用 ember-simple-auth ( https://github.com/simplabs/ember-simple-auth/ )中的 invalidateSession() 操作。

我通常像他们在示例中那样使用它:{{ action 'invalidateSession' }}在我的车把模板中。preLogout在我打电话之前我需要做一些事情,invalidateSession()所以需要有一种方法 - 但目前我无法弄清楚如何。

模板:

{{ action 'preLogout' target='view' }}

看法:

actions:{
    preLogout:function(){
        this.get("controller").send("preLogout");
    }
}

控制器:

actions:{
    preLogout: function(){
    var self = this;
    //some preLogout things to do
    //INVALIDATESESSION - how?
    this.transitionToRoute("index");
}

谢谢

4

1 回答 1

4

最好的方法是覆盖invalidateSession操作并_super在您没有​​必要的操作后调用,例如:

// app/routes/applications.js
export default Ember.Route.extend(ApplicationRouteMixin, {
  actions: {
    invalidateSession: function() {
      // do custom stuff…
      this._super();
    }
  }
});
于 2014-07-30T11:27:13.130 回答