Add Admin Role to T3 Stack
Hi, not sure what I'm missing for this
in user Schema
and then the enum for Role.. thats okay,
---
Then I tried to make a protected middleware, and noticed that session.user is only showing 4 values, role is missing, but many others too (first picture),
-- Adding role to next-auth.d.ts fixed the type definition and role appears, but the issue persists as it returns undefined instead of the role (second pic)
Any idea? Not sure what I have to do to retrieve more than those 4 values from User schema
Thanks š
8 Replies
-------
like @nexxel said, these appears because they are default by Next?
https://i.imgur.com/Tv9qx22.png
---
How would you fetch the role for make the protected routes? and how normal values?
https://i.imgur.com/mCjzFaZ.png I guess this is the way? but role does not exists on that type
what you can do is start the user id with the role name e.g admin , then check that the first 4 letters of id are admin
@brr hey, actually this works, the
session.user.role = user.role
š
but.. it still gets the TS issue
somehow I have to add a new role?
hmm not sure sorry
with the role? it fixed the TS issues, ill close the post idk