Role based Authentication Question

I was looking to have an isAdmin middleware like option 2 here: https://trpc.io/docs/authorization However, my "role" field that isn't available in my context. How do I add it to my context? Sorry if thats a dumb q im new lol
Authorization | tRPC
The createContext function is called for each incoming request, so here you can add contextual information about the calling user from the request object.
6 Replies
joshborseth
joshborsethOP•2y ago
joshborseth
joshborsethOP•2y ago
pretty sure that was what i needed think it works now?
arete
arete•2y ago
GitHub
GitHub - FatwaArya/hotel-booking
Contribute to FatwaArya/hotel-booking development by creating an account on GitHub.
arete
arete•2y ago
look at the [...nextauth].ts, next-auth.dts, and trpc.ts on server folder thats how i do role based but dk the thats the best solution lol
joshborseth
joshborsethOP•2y ago
thanks man, thats the exact way i ended up doing it. Just felt so wrong going in and like declaring the types when so much of this stack is inferred haha 😉
arete
arete•2y ago
trueee
Want results from more Discord servers?
Add your server