user2517182
user2517182

Reputation: 1299

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.

Upvotes: 2

Views: 445

Answers (1)

Stéphane Bruckert
Stéphane Bruckert

Reputation: 22923

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'
};

Upvotes: 2

Related Questions