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
Create T3 App
NextAuth.js 🚀 Create T3 App
The best way to start a full-stack, typesafe Next.js app.
pretty sure that was what i needed
think it works now?
GitHub
GitHub - FatwaArya/hotel-booking
Contribute to FatwaArya/hotel-booking development by creating an account on GitHub.
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
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 😉
trueee