Understanding Role Retrieval in Guards
Learn how to retrieve roles in guards.
Before we delve into creating the AccessControlGuard
for effective role-based access control, we must understand how to retrieve the role we’ve passed to the Roles
decorator. In this lesson, we’ll apply the Roles
decorator at the controller and method levels. Subsequently, we’ll demonstrate how to retrieve the corresponding roles within the AuthGuard
. The code in this lesson serves practical demonstration purposes only, and it will not be in our final application.
Applying a decorator at the controller level
Applying the Roles
decorator at the controller level sets the specified roles for all route handlers within that controller.
Get hands-on with 1400+ tech skills courses.