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

fix(next-auth): force session.update() to trigger session update #11024

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chriseling
Copy link
Contributor

@chriseling chriseling commented May 28, 2024

When calling session.update() without data, data will be undefined. If data is undefined, then req is undefined and in fetchData when req.body is not defined, the method will not be set to POST nor will the csrf token be included. I think that is why when you call session.update(), it doesn't actually trigger an update and the only way to get it to trigger an update is to call the function with data. Maybe this is by design, but it was confusing as I would expect session.update() to trigger a session update even without providing data (in the case where session data or user data has changed elsewhere)

☕️ Reasoning

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

When calling session.update() without data, data will be undefined.  If data is undefined, then req is undefined and in fetchData when req.body is not defined, the method will not be set to POST nor will the csrf token be included.  I think that is why when you call session.update(), it doesn't actually trigger an update and the only way to get it to trigger an update is to call the function with data.
Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) May 28, 2024 6:52am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview May 28, 2024 6:52am

Copy link

vercel bot commented May 28, 2024

@chriseling is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 38.74%. Comparing base (770112c) to head (0ad3427).

Files Patch % Lines
packages/next-auth/src/react.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11024   +/-   ##
=======================================
  Coverage   38.74%   38.74%           
=======================================
  Files         176      176           
  Lines       27887    27885    -2     
  Branches     1217     1223    +6     
=======================================
  Hits        10804    10804           
+ Misses      17083    17081    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ndom91 ndom91 changed the title Fix session.update() to trigger session update fix(next-auth): force session.update() to trigger session update Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant