0

There is one problem,

I want to set the routeIfAlreadyAuthenticated route in environment as the route with dynamic segment(/:userid/dashboard) which is based on the logged-in user.

How can i do that?

//config/environment.js
  ENV['ember-simple-auth'] = {
    authorizer: 'authorizer:custom',

    routeAfterAuthentication: '/dashboard',
    routeIfAlreadyAuthenticated: '/dashboard'
  };
Navneet
  • 4,543
  • 1
  • 19
  • 29

1 Answers1

0

I don't think you have that ability in the config/enviroment.js file. What I think you can do is redirect to some route you have, and use that route to redirect to the place you want. Like:

//config/environment.js
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:custom',

routeAfterAuthentication: '/some-route',
routeIfAlreadyAuthenticated: '/some-route'
};

//router.js
this.route('some-route', { path: '/some-route' });
this.route('user-dashboard', { path: '/:id/dashboard' });

//some-route.js
export default Ember.Route.extend({
  userSession: Ember.inject.service(),
  beforeModel() {
   const user = userSession.get('currentUser'); 
   this.transitionTo('user-dashboard', user);
  }
});

This example assumes that you have some sort of user-session service where you can .get('currentUser')which is the logged in user. So that you can pass that model to the transitionTo method.

Hope it helps.

Pedro Rio
  • 1,444
  • 11
  • 16