ember-simple-auth icon indicating copy to clipboard operation
ember-simple-auth copied to clipboard

Session stores require @classic

Open maxwondercorn opened this issue 4 years ago • 3 comments

Session stores extend from the Ember object so you do need the @classic decorator when using native class syntax.

This should be documented in the README. If you like, I can create a PR.

maxwondercorn avatar Feb 01 '21 19:02 maxwondercorn

@marcoow Is there a way to avoid using @classic when extending the Cookie store?

import classic from 'ember-classic-decorator';
import Cookie from 'ember-simple-auth/session-stores/cookie';

@classic
export default class ApplicationSessionStore extends Cookie {}

There is an ongoing issue in ember-classic-decorator (https://github.com/emberjs/ember-classic-decorator/pull/83) preventing apps to upgrade to Ember 4.

And I can't remove ember-classic-decorator from my app as long as ember-simple-auth requires it.

Any suggestion would be greatly appreciated, thanks!

gzurbach avatar Jan 07 '22 12:01 gzurbach

The fix for ember-classic-decorator #83 has been fixed and merged so this is no longer a blocker to Ember 4.

maxwondercorn avatar Apr 02 '22 21:04 maxwondercorn

I am in the process of updating our app to [email protected]. Lots of good stuff in there!

I was wondering if I could remove the @classic decorator from my ApplicationSessionStore, but it seems like it's still necessary?

The app crashes with this error message in the console:

Error: You defined the class ApplicationSessionStore that extends from EmberObject using native class syntax, but you didn't mark it with the @classic decorator. All user classes that extend from this class must be marked as @classic, since they use classic features. If you want to remove the @classic decorator, you must remove the base class. For components, you can do this by converting to Glimmer components. For plain classes that extend from EmberObject, you can convert them into plain native classes that do not extend from EmberObject.

The code triggering this error:

import Cookie from 'ember-simple-auth/session-stores/cookie';

export default class ApplicationSessionStore extends Cookie {
  cookieExpirationTime = 30 * 24 * 60 * 60;
}

Are there any plans to convert classes from EmberObject to native classes at some point? This is the last @classic decorator left in the app :)

A big thank you to the maintainers for your hard work!

gzurbach avatar Aug 21 '23 20:08 gzurbach