Ember Simple Auth: routeIfAlreadyAuthenticated vs routeAfterAuthentication


#1

Can anybody explain what is the difference between these 2 methods in Ember Simple Auth:

routeAfterAuthentication

and

routeIfAlreadyAuthenticated

I have 2 apps that have these two parameters defined in environment.js and I’d like to know when to use one or another. Thank you.


#2

They are two different things:

  • routeAfterAuthentication is where to transition after a successful login.
  • routeIfAlreadyAuthenticated is where to go if the user is already authenticated and visits a page which makes no sense to visit if you’re logged in (login, register, a guest homepage, etc.)

#3

Hi Balint! Thank you for your response. So following your book, where we have it defined as follows in environment.js:

# environment.js
module.exports = function(environment) {
  let ENV = {
...
 'ember-simple-auth': {
      routeIfAlreadyAuthenticated: 'bands'
    },
...

it seems like there is no difference in which one to use, both will make the transition to bands route. Right ?


#4

The two config variables have different meanings but in some cases they might overlap, like in the Rock and Roll app. The important thing is to see how they differ.


#5

Ok, got it, thank you very much !