Road to 2.0: how to transitionTo if no controllers are involved?


As controllers will be removed, I am implementing an authentication service using… well, a service. In the beforeModel hook of a route I call the authentication service in order to check if the user is authenticated.

Ideally I would want to handle all the authentication related stuff within the service, so I would need to redirect to the login route in case the user is not logged in. However this does not seem to be possible from the service, as the service does not seem to support an appropriate method to do so.

No problem here, I can make the transition call to the login route from the route that is protected, then call the authentication service and handle the authentication. However, now I am stuck within the authentication service having to redirect back to the protected route.

Yeah… no problem. let’s just return a Promise in the authentication Service and then let the login route handle the transition when the promise is resolved.

However, If I call resolve(transition) and provide the old transition as an argument, I end up with an error that the transition has been aborted and the error hook is called?!? (what?!?) So, I need to wrap the transition within an object like: resolve({t: transition}); That at least passes the transition to the login route.

Can somebody please give a hint how to handle this the ember 2.0 way without all that pain involved?