for next-auth how to include a different model to a User Object
What i want
so that i can attach the user. teacher in the
The goal is to use that teacher object to verify certain things.
Thanks
39 Replies
1:
2:
Oh thanks for the answer, I think i need to be more specific next time
The above code solves the problem which it will include the teacher object but if you take a look at my model
I added a relation to a teacher model
So even i added the teacher object to the session, it will undefined
You need to fetch it from db in your createContext I believe?
Where do i do that @julius
Thanks for helping
Im assuming its here
but it didnt attach it to the
@julius
The useSession uses the object from the session callback you changed previously. But imo I wouldn’t attach to much stuff to the useSession hook
Tried doing it in the callback session also but i dont want to call prisma there haha
Just do a user.me procedure or smth
And you can attach the teacher there
The session object is stored in cookies (I think?) and you don’t want too big object there
Sorry i dont understand the user.me procedure part . Do you have any examples that you can share if you dont mind
Gimme sec at my pc soon
Okay julius take ur time, thanks for helping
This is under trpc router right?
yea i placed it just in the approuter now but if you have a user router that's prob better
consider that the createContext function is called on every request so you want it to be as minimal as possible to not block unnecessary
Okay understood, the thing is i need the teacher object to present in the session globally so that i can use it whenever i can like
in Navbar etc...
so example
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View