Skip to content

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

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

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.
@chriseling chriseling requested a review from ThangHuuVu as a code owner May 28, 2024 06:51
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 line in your changes missing coverage. Please review.

Project coverage is 38.74%. Comparing base (770112c) to head (0ad3427).
Report is 472 commits behind head on main.

Files with missing lines 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
Copy link

stale bot commented Jan 31, 2025

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-auth stale Did not receive any activity for 60 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy