Ember-simple-auth: Configuring routeAfterAuthentication in 3.1.0 without mixins

Created on 29 Aug 2020  路  6Comments  路  Source: simplabs/ember-simple-auth

When replacing the ESA mixins with the new 3.1.0 features, how do you configure routeAfterAuthentication?

question

Most helpful comment

I ended up overwriting the default 'index' route as well. I do think it would be worth a note in the change log / upgrade guide on this topic as I expect others will have the same question.

All 6 comments

curious about this too

This is working for me now. I'm not sure if it's the "correct" approach:

import ESASessionService from 'ember-simple-auth/services/session'
import { inject as service } from '@ember/service'

export default class SessionService extends ESASessionService {
  @service currentUser

  handleAuthentication() {
    super.handleAuthentication('profile')

    this.currentUser.load().catch(e => {
      console.error(e)
      this.invalidate()
    })
  }
}

I'm overwriting the default 'index' route with 'profile'.

@ballPointPenguin's approach is indeed the correct and suggested approach.

I ended up overwriting the default 'index' route as well. I do think it would be worth a note in the change log / upgrade guide on this topic as I expect others will have the same question.

I believe the way to do this works the same as pre-3.1.0: inside the config environment. However, there was a bug with the lookup being used to fetch that config which isn't yet released in the 3.1.0 beta tags (https://github.com/simplabs/ember-simple-auth/issues/2231). Until that gets released you have to double-nest the config. I'd recommend doing both so you're ready for the upgrade, and able to use the workaround for now:

// config/environment.js
// ...

'ember-simple-auth': {
  routeAfterAuthentication: 'profile',
  'ember-simple-auth': {
    routeAfterAuthentication: 'profile',
  },
}
Was this page helpful?
0 / 5 - 0 ratings