-
-
Notifications
You must be signed in to change notification settings - Fork 5
Update hank-elements to v2 #355
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
base: main
Are you sure you want to change the base?
Conversation
β¦ent multiple instances that poll /session/validation
src/runtime/composables/index.ts
Outdated
| cookieDomain: hankoConfig.cookieDomain, | ||
| }) | ||
|
|
||
| const hanko = useState( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably use nuxtApp.provide('hanko', hankoInstance) (and then nuxtApp.$hanko) rather than useState as state is really meant to be for data that could be passed from server -> client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree.
I've changed it to a provide from within the client plugin and added the types there as well.
My second commit is updating the documentation and inner usage of the provided $hanko instead of useHanko()
I kept useHanko alive because of compatibility.
I hope you agree on this.
Thanks for the catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather keep useHanko (and use everywhere instead of nuxtApp.$hanko) but we can return nuxtApp.$hanko inside it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I reverted it within the src folder
β¦or Hanko instance
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
===========================================
+ Coverage 36.82% 83.87% +47.04%
===========================================
Files 16 1 -15
Lines 410 31 -379
Branches 25 8 -17
===========================================
- Hits 151 26 -125
+ Misses 245 3 -242
+ Partials 14 2 -12 β View full report in Codecov by Sentry. π New features to boost your workflow:
|
π Linked issue
#3
This change does require a new major version!
β Type of change
π Documentation (updates to the documentation or readme)
π Bug fix (a non-breaking change that fixes an issue)
[x ] π Enhancement (improving an existing functionality)
π Description
Every running instance of Hanko does a session/validate ever so often.
When using useHanko on multiple plugins / middleware / pages, a lot of instances are polling.
We can prevent that by using useState
Hank elements are currenlty on v 2.3.
I've updated the package and places that have changed so the middleware works again