Get session data inside a mutation
Hello. So im trying to create a profile inside a user that is already logged in.
So the flow is Create User => Login => Create User Profile Inside the app.
My Models:
Im failing to understand how do I get the session that is logged .. or do I even need it ?
8 Replies
If you need the user session
Use a protected procedure
And on the ctx you will have the user session
Oh i completly forgot i can use that
Much better. Thank you!
Now looking at my models, i might want to rethink whats in user and whats in profile too!
Anyway, Thank you!
It probably doesn't apply in this case, but you can still access
ctx.session?.user
in public procedures, just make sure the user is not undefined. It can be useful in some situationsUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
Im not doing that YET. On my part i have a button to go to profile page but yes the objective is to detect user sign in for the first time and if so, you complete your profile.
So you may want something like this:
https://stackoverflow.com/questions/70739015/next-auth-check-if-user-signs-in-for-the-first-time
Stack Overflow
Next-auth check if user signs in for the first time
How to check if the it's the first time the user signs in using Next-Auth?
I have tried implementing the newUser page following the official documentation, but it doesn't really seem to work. This ...
For me I use a model User and a model Profile
Like this
So signup you create the user -> is first time sign in ?
complete user profile : navigate app and eventually update user profile
complete user profile : navigate app and eventually update user profile
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yeah tbh I created an user the good old way, have to see that tomorrow.