How to add extra user DB fields into context

Hey guys, trying to solve authorisation. I have an isAdmin field added to my user. My idea was I would just create a TRPC middleware similar to protected procedure but check ctx.session.user.isAdmin. Issue is, only name, email, id and image is returned on ctx.session.user: I watched the Theo vid on authorisation, but thought it would be cleaner rather than an extra separate api call to just include it in the context and middleware. How can I achieve this?
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
rocawear
rocawear2y ago
If you scroll down abit you can see next auth type
cje
cje2y ago
^ this is true, but also i would in general suggest to put as little on the user model as you reasonably can, even if it means your db queries are a bit more expensive
Cody
Cody2y ago
Knew the solution would be simple. The t3 docs are great, need to refer to them more. Thankyou so much!
Want results from more Discord servers?
Add your server