You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Next.js Server Action that needs to validate a user is signed in as a specific user.
As things currently stand, I don't think there's a way to do this. You can't use a React hook inside a server action since it isn't a React component. the siweServer has a getSession method, but this expects you to have access to the req/res, which you don't in a server action.
My specific use case: I have a server action that handles when a user clicks on a button. If a user is either not SIWE signed in OR they are signed in but not the correct user, it needs to throw an error.
The only thing I can think of is what I was doing before I switch to using connectkit, when I was using iron-session to store the SIWE cookie and manually pulling the cookie, e.g. I used to have:
But given the connectkit docs don't talk about how SIWE cookies are stored behind the scenes, this feels at best like a brittle approach that might break in a future version of connectkit. And it would require me reverse-engineering connectkit code to figure out exactly how the cookie is accessed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a Next.js Server Action that needs to validate a user is signed in as a specific user.
As things currently stand, I don't think there's a way to do this. You can't use a React hook inside a server action since it isn't a React component. the siweServer has a
getSession
method, but this expects you to have access to thereq
/res
, which you don't in a server action.My specific use case: I have a server action that handles when a user clicks on a button. If a user is either not SIWE signed in OR they are signed in but not the correct user, it needs to throw an error.
The only thing I can think of is what I was doing before I switch to using connectkit, when I was using iron-session to store the SIWE cookie and manually pulling the cookie, e.g. I used to have:
and then a server action that included:
But given the connectkit docs don't talk about how SIWE cookies are stored behind the scenes, this feels at best like a brittle approach that might break in a future version of connectkit. And it would require me reverse-engineering connectkit code to figure out exactly how the cookie is accessed.
Surely there's a better way than this?
I'd love to be able to go
or something to that effect.
Beta Was this translation helpful? Give feedback.
All reactions