Role switching, JWT or Client side?
Unanswered
Capple posted this in #help-forum
CappleOP
Hello,
I'm using Nextauth and Prisma. I need to implement role switching. The user currently has roles array e.g ["ADMIN", "USER"]. My current solution just checks if "ADMIN' exists in the roles array in both frontend and in my API routes.
What would be the best way of handling this? Should I add currentRole property in my JWT and then update it client side upon role switch with the getSession update function
I'm using Nextauth and Prisma. I need to implement role switching. The user currently has roles array e.g ["ADMIN", "USER"]. My current solution just checks if "ADMIN' exists in the roles array in both frontend and in my API routes.
What would be the best way of handling this? Should I add currentRole property in my JWT and then update it client side upon role switch with the getSession update function
const { data: session, update } = useSession(); and in the JWT callback?