0

So I have been setting up a auth manager through my ember for the past week a and finally got it working. However, I'm still getting a error when invalidating the user.

Nothing handled the action 'sessionInvalidationSucceeded'

Can't figure out what the best way to handle the error?

import Ember from 'ember';
import DS from 'ember-data';

export default Ember.Object.extend({
 authenticate: function(controller, user) {
  var app = this.container.lookup('controller:application');
  var session = app.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', user);
  session.then(function() {
    console.log('Session Started');
    controller.transitionToRoute('brands');
  });
 },
 endSession: function() {
  var app = this.container.lookup('controller:application');
  var session = app.get('session').invalidate();
  session.then(function() {
   app.store = DS.Store.create();
   console.log('Session Ended');
   app.transitionToRoute('index');
   app.store.destroy();
  });
 }
});


import Ember from 'ember';

export default Ember.Controller.extend({
 actions: {
   sessionEnded: function() {
    this.authManagerService.endSession();   
   }
 },
 currentUser: function() {
  return this.store.find('user', this.session.get('user_id');
 }.property('@each.user')
});
Thomas Davis
  • 188
  • 1
  • 9

1 Answers1

0

You need to include the Simple Auth Route mixin on the route you are authenticating

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

or handle the action in your initializer

Ember.Application.initializer({
  name:       'authentication',
  after:      'simple-auth',
  initialize: function(container, application) {
    var applicationRoute = container.lookup('route:application');
    var session          = container.lookup('simple-auth-session:main');
    // handle the session events
    session.on('sessionInvalidationSucceeded', function() {
      applicationRoute.transitionTo('index');
    });
 }
});

Take a look at the api, it's really helpful http://ember-simple-auth.com/ember-simple-auth-api-docs.html#SimpleAuth-ApplicationRouteMixin-sessionInvalidationSucceeded

Tyler Iguchi
  • 1,074
  • 8
  • 14
  • the `sessionAuthenticationSucceeded` should never be triggered if the `ApplicationRouteMixin` isn't used. Maybe it's mixed in into the wrong route though? – marcoow Apr 07 '15 at 08:33