adopted-ember-addons / ember-cognito

AWS Amplify/Cognito and ember-simple-auth integration
MIT License
32 stars 25 forks source link

Issue integrating with fastboot #148

Open napafundi opened 4 years ago

napafundi commented 4 years ago

When using ember-cognito with fastboot, page refreshing logs the user out.

After refreshing, I get an error : The authenticator "authenticator:cognito" rejected to restore the session - invalidating…. This doesn't occur when fastboot is disabled. I'm using a CookieStore as described in the ember-simple-auth docs as well as a current-user service as described in docs here.

paulcwatts commented 4 years ago

Hi @napafundi , sorry for taking so long to get back to you.

Unfortunately I've not found much success with using the CookieStore, Cognito and Fastboot. The biggest issue is that the JWT created by Cognito is too large to be stored in the cookie store.

I'm not sure what is causing the restore to be rejected -- you can try debugging into the authenticator's restore method to see. But I suspect it has something to do with the issues of the cookie being too large.

hoIIer commented 2 years ago

@napafundi as a workaround you can do:

export default class IndexRoute extends Route {
  @service fastboot;
  @service session;

  beforeModel(transition) {
    if (!this.fastboot.isFastBoot) {
      this.session.requireAuthentication(transition, 'login');
    }
  }
}

Depending how you're running fastboot and what your needs are, having auth info may only be required when the regular app loads.