nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
24.79k stars 3.49k forks source link

Add ability to update the session/jwt from the server #7342

Open camsloanftc opened 1 year ago

camsloanftc commented 1 year ago

Description πŸ““

The new update function from useSession is good, but it has to be triggered from the client.

It would be great if we could trigger the updates from the server.

I like how blitzjs handles this with a $setPublicData function. (It's also nice to have the $setPrivateData function as well, but I can live without that).

I think in most cases this would be a more elegant way to update the session, rather than having to authorize and validate the client sessions from the current update implementation.

How to reproduce β˜•οΈ

N/a

Contributing πŸ™ŒπŸ½

Yes, I am willing to help implement this feature in a PR

DiegoGonzalezCruz commented 1 year ago

Hi! Do you think that would be useful to update other users jwt?

camsloanftc commented 1 year ago

I don’t think you could set another users JWT like this since JWT is stateless, and no info is retained on the server.

If you used database sessions then you could update sessions for other users by a similar technique.

khuezy commented 1 year ago

I think this would be useful. I currently hack around this by manually encoding/decoding the next-auth.session-token to update it.

maccman commented 1 year ago

I definitely think this makes sense. I want to store some redirect params in there.

itsbetma commented 1 year ago

I think it can be a great feature, currently, I am implementing a feature that would take advantage of this.

knightrun commented 1 year ago

I need a feature to update sessions on the server in my project. Is this feature under development? If so, when do you expect it to be completed?