Search code examples
javascriptember.jsember-simple-auth

Redirect to index page if user is not authenticated


I'm using ember-cli-simple-auth with ember-cli-simple-auth-token:

"ember-cli-simple-auth": "^0.8.0",
"ember-cli-simple-auth-token": "^0.7.3"

And i already made all configurations with my server to receive the token if the credentials matches with some user in my database.

My doubt now is how can i force redirect if a user tries to access one page if is not log in?

I'm using the following:

export default Ember.Route.extend(AuthenticatedRouteMixin, {});

And this is causing a blank page if the user is not authenticated.. but the redirect doesn't happen.. Am i missing some config here?


Solution

  • You need to change authenticationRoute:

    // config/environment.js
    ENV['ember-simple-auth'] = {
      authenticationRoute: 'index' // or '/' or 'application'
    };