0

At the moment i'm facing the problem that I need to use the invalidateSession() action from ember-simple-auth (https://github.com/simplabs/ember-simple-auth/) in one of my own controllers.

I normally use it like they do in their examples: {{ action 'invalidateSession' }} in my handlebars-template. I need to do some preLogout stuff before I call invalidateSession() so there needs to be a way - but at the moment I can't figure it out how.

Template:

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

View:

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

Controller:

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

Thanks

DominikAngerer
  • 6,354
  • 5
  • 33
  • 60

1 Answers1

4

The best way to do that is to override the invalidateSession action and call _super after you're don't with the necessary actions, e.g.:

// app/routes/applications.js
export default Ember.Route.extend(ApplicationRouteMixin, {
  actions: {
    invalidateSession: function() {
      // do custom stuff…
      this._super();
    }
  }
});
marcoow
  • 4,062
  • 1
  • 14
  • 21
  • I will give this a chance - but as it had to be finished very soon I will have to make a little hack at the moment - came up with the idea using a button in the template with this action which won't show up for the user and I will click it with a little nasty helper in the controller. I will come back! – DominikAngerer Jul 30 '14 at 12:05