See JSFiddle: Ember transition.retry looses ID - JSFiddle - Code Playground
There are a lot of samples that show how to implement authentication in Ember. To protect access to a route, you will be redirected to a login page if you do not have a valid token. After succesful login (thus after obtaining a valid token), you will be redirected to the initial requested page.
Implementation: before the redirect to login, you store the requested transition in an object; after login, you read the object property and do a transition.retry.
login: function () { var self = this;
App.Session.set('token', '1234567890');
var attemptedTransition = App.Session.get('attemptedTransition');
if (attemptedTransition) {
attemptedTransition.retry();
}
....
This works well if you access the application via the root URL. You can see this in the JSFiddle. Click on publications to see a list of publications. Then, if you click a publication to see the details you have to login. Click on login (just simulates a succesful login) and you are transitioned to the “details” route.
If you however access a “detail” URL directly (e.g. browse to http://yyy/index.html#/publications/1), then the .retry on the stored transition fails. It seems like in that case, the ID (param of the route) is lost. The url becomes: http://yyy/index.html#/publications/undefined …
Is this a known problem ? Is there a workaround ?
FURTHER INFO:
If you inspect the transition then in case it does not works, the providedModelsArray is not set. Has this something to do with Ember.data ?
Correct transition (Ember.inspect(savedTransition)):
{router: [object Object], promise: [object Object],
data: [object Object], resolvedModels: [object Object],
providedModels: [object Object],
providedModelsArray: <App.Publication:ember330:2>,
sequence: 2, params: [object Object],
targetName: publications.show, isAborted: true}
Incorrect transition (Ember.inspect(savedTransition)):
{router: [object Object], promise: [object Object],
data: [object Object], resolvedModels: [object Object],
providedModels: [object Object],
providedModelsArray: ,
sequence: 1, params: [object Object],
targetName: publications.show,
urlMethod: null, isAborted: true}