Reputation: 1
I am currently trying to override sessionAuthenticationSucceeded
in the Ember.SimpleAuth.ApplicationRouteMixin
class, so that I can transition into my routeAfterAuthentication
with a model passed in.
Basically this.transitionTo(Configuration.routeAfterAuthentication, model);
, but even after doing Ember.SimpleAuth.ApplicationRouteMixin.reopen()
my override of the function is never called. So am I going about this all wrong? Can Mixins not be reopened in this fashion? Or should I be passing the model to the routeAfterAuthentication
transition in a different fashion.
EDIT: Stupid reputation limits, was gonna answer this myself but apparently have to wait 8 hours, so here is that answer for now:
Well, not entirely sure if this is the correct way to do this, but it works. I was looking through this example: custom-server and I wound up doing this to accomplish what I wanted.
var applicationRoute = container.lookup('route:application');
var session = container.lookup('ember-simple-auth-session:main');
var store = container.lookup('store:main');
session.on('sessionAuthenticationSucceeded', function() {
var user = store.find('user', session.get('user_id'));
container.lookup('controller:application').set('content', user)
applicationRoute.transitionTo('profile.resume', user);
});
Upvotes: 0
Views: 1004
Reputation: 4062
The easiest solution would be to simply define the sessionAuthenticationSucceeded
on the application route instead of reopening the mixins:
/// routes/application.js
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin, {
actions: {
sessionAuthenticationSucceeded: function() {
…
}
}
})
Upvotes: 1
Reputation: 1
Well, not entirely sure if this is the correct way to do this, but it works. I was looking through this example: custom-server and I wound up doing this to accomplish what I wanted.
var applicationRoute = container.lookup('route:application');
var session = container.lookup('ember-simple-auth-session:main');
var store = container.lookup('store:main');
session.on('sessionAuthenticationSucceeded', function() {
var user = store.find('user', session.get('user_id'));
container.lookup('controller:application').set('content', user)
applicationRoute.transitionTo('profile.resume', user);
});
Upvotes: 0