Search code examples
ember.jsember-simple-auth

Ember Simple Auth: no need for /login route?


Login form in my app is realized via hidden form (which overlays the page and is displayed through data-toggle).

It is nice and user friendly, however the problem occurs when unauthenticated user wants to access protected route - Ember Simple Auth wants to redirect to /login. How to display login form in that case?


Solution

  • It's easy - in your application route override an sessionRequiresAuthentication action. This action is defined in application-route-mixin, and by default looks like:

    sessionRequiresAuthentication: function() {
      this.transitionTo(Configuration.authenticationRoute);
    },
    

    Instead of transitioning you may write a code to open a login form