ember-simple-auth: Problem with Current User docs and implementation
It appears that a vitally important resolve() is missing from the current user documentation. It does appear in the dummy code;
Additionally it appears as if this solution cannot be used reliably due to its async nature. Obviously the beforeModel hook is not async since Ember waits for all the Promises to resolve before continuing, but the sessionAuthenticated event is async, so if it takes longer for the promise to resolve than it takes to render the next route, the transition will blow up.
Specifically what I’m doing is transitioning to dashboard after authentication. In the dashboard route I have a beforeModel that checks to see if the logged in user has taken the tour yet, if they have, I show them the dashboard, if they haven’t I transitionTo the tour.
Because the current user promise hasn’t resolved, the service doesn’t have a user and the transition blows up.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (3 by maintainers)
@manuelsteiner and @thegranddesign here is my solution to this problem. Rather than extending
sessionAuthenticatedmethod fromApplicationRouteMixin, I took its contents and run after current user promise resolves. See below. Notice how I removedthis._super(...arguments).@KrisOlszewski good solution thank you. You would use
this.transitionTo(get(this, 'routeAfterAuthentication'))instead ofthis.transitionTo('dashboard');to transit to the configured route.