0
votes

I am trying to prompt the user with a modal that requires the confirmation of his/her password, before the transition to a given route (in this case my App.UserSettingsRoute). I've got this to work generally (I'm opening the modal and aborting the transition in the beforeModel hook, and resume the transition when the password is confirmed), but I'm facing the following problem:

When the user enters the route directly (by typing in the URL in the address bar directly or by refreshing the browser while in the route), I cannot open the modal (I get an error) because I have not yet entered any route yet - this is the first route being entered in the application. My question: How can I detect that the current route I am entering is the first one? Alternatively, is there a better approach for this?

1

1 Answers

0
votes

I've implemented this method from webcloud:

http://webcloud.github.io/blog/2014/04/07/emberjs-authentication-the-right-way-javascript-version/

You can also use the:

App.ApplicationRoute = Ember.Route.extend({
    beforeModel: function(transition, queryParams){
        // Do auth here...
    }
});

This route is always hit first no matter what route in your app the visitor directly types in.