javascriptember.jsoverridingember-simple-auth

Ember ember-simple-auth override routeIfAlreadyAuthenticated in application route


How do you override the routeIfAlreadyAuthenticated?

And once that happens, how can it transition to a route with a dynamic segment?

I realize I can override sessionAuthenticated; and in that ways override the functionality of routeAfterAuthentication. However, routeIfAlreadyAuthenticated is a computed property that is executed in a beforeModel in the unauthenticated-route-mixin.js mixin.

Any help would be greatly appreciated.


Solution

  • In app/session/route.js, just do:

    import Ember from 'ember';
    import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
    
    export default Ember.Route.extend(UnauthenticatedRouteMixin, {
      routeIfAlreadyAuthenticated: 'dashboard'
    });
    

    and it works, no more:

    Error while processing route: session.login Assertion Failed: The route index was not found Error


    The following works as well, but is deprecated

    In config/environment.js:

    var ENV = {
       ...
    };
    
    ENV['ember-simple-auth'] = {
       // authenticationRoute:          'login',
       // routeAfterAuthentication:     'dashboard',
       routeIfAlreadyAuthenticated:  'dashboard'
    };