Admin dashboard

How could I create an admin dashboard where if the user is not authenticated with next-auth it goes to /login but if he does not have admin give a 403 ? Maybe something like roles ?
Solution:
Role-based access control | Auth.js
There are two ways to add role-based access control (RBAC) to your application, based on the session strategy you choose. Let's see an example for each of these.
Jump to solution
3 Replies
.traevelliath
.traevelliath2y ago
Definitely roles do need to be involved. Once you set them up, you can use getServerSideProps to redirect ( return {redirect: ... } ) or throw 403.
lecookie
lecookieOP2y ago
Is there anything in next-auth that does the role easily ?
Solution
.traevelliath
.traevelliath2y ago
Role-based access control | Auth.js
There are two ways to add role-based access control (RBAC) to your application, based on the session strategy you choose. Let's see an example for each of these.

Did you find this page helpful?