Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session stores require @classic #2267

Open
maxwondercorn opened this issue Feb 1, 2021 · 3 comments
Open

Session stores require @classic #2267

maxwondercorn opened this issue Feb 1, 2021 · 3 comments

Comments

@maxwondercorn
Copy link

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.

@gzurbach
Copy link

gzurbach commented Jan 7, 2022

@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 (emberjs/ember-classic-decorator#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!

@maxwondercorn
Copy link
Author

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

@gzurbach
Copy link

I am in the process of updating our app to ember-simple-auth@6.0.0. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants