I'm using Ember CLI and integrated the Simple Auth Addon successfully. Unfortunately I'm facing an issue at the moment that I can't seem to get the sessionAuthenticationFailed
action in my project's ApplicationRoute
triggered. I already did this successfully with the browserified version of Ember Simple Auth but I really want to use the Addon for Ember CLI now and also figure this out! At the moment my ApplicationRoute
looks like this in Coffescript:
`import Ember from 'ember'`
`import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin'`
`import Session from 'simple-auth/session'`
ApplicationRoute = Ember.Route.extend ApplicationRouteMixin,
actions:
sessionAuthenticationFailed: (error) ->
debugger
`export default ApplicationRoute`
I also tried reopening the ApplicationRouteMixin and setting a debugger
in the function, which also didn't work. As far as I can follow the source code of Ember Simple Auth the Session
triggers the event by calling _this.trigger('sessionAuthenticationFailed', error)
in its authenticate
function. I also compared the working version with the one that's not working at the moment and when I step through the code after the trigger is called, I end up in the sendEvent
function which receives an object, in this case it's the Ember Simple Auth Session
, an eventName, params and actions. What's interesting here is that some meta data about listeners is read from the Session in this part of code:
var meta = obj[META_KEY];
actions = meta && meta.listeners && meta.listeners[eventName];
In my case meta.listeners[eventName]
is undefined
meaning there are no listeners to the sessionAuthenticationFailed
event and therefore nothing is called on anything and I'm ending up not catching the event with my action.
Now the big question is of course why it don't seem to register any listeners for this event. Is anyone else already using the Ember CLI Simple Auth Addon and successfully hooked the sessionAuthenticationFailed
event? If so help would be appreciated!
Cheers, Dave!
Edit By reading the comments of the source I saw that if a beforeModel hook is used in the extending ApplicationRoute I have to call the parent's beforeModel function by this._super() as well. I think I'm one step closer to solving this!
Ok, I solved this. So I implemented the beforeModel(transition)
hook in my ApplicationRoute
to load translations but didn't call the parent function with this._super(transition)
. This could be one of the reasons why it's not working if you have the same problem as I described!