Nirmalya Ghosh
Nirmalya Ghosh

Reputation: 2520

Route after authentication in Ember

According to the docs, I should put routeAfterAuthentication in my config/environment.js file.

My environment.js contains the following:

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'client',
    environment: environment,
    baseURL: '',
    locationType: 'auto',
    routeAfterAuthentication: 'dashboard',
...

However, it's still not getting redirected to the dashboard route and showing that the index route is not defined.

Am I missing something here?

Upvotes: 0

Views: 299

Answers (1)

Mirza Memic
Mirza Memic

Reputation: 872

You will need to include ember-simple-auth key like this

 var ENV = {
 };
 ...
  ENV['ember-simple-auth'] = {
    authenticationRoute: 'sign-in',
    routeAfterAuthentication: 'YOUR ROUTE GOES HERE'
  }
...

You can also define them by environment inside if (environment === 'development'), but for all environments you can put them after var ENV declaration. It is also important to import application route mixin so that redirect works (app / routes / application.js)

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';


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

Upvotes: 6

Related Questions