Route Guard
Securing the routes of your project with ModularBr.
Last updated
Securing the routes of your project with ModularBr.
Last updated
The Route Guard of ModularBr is a middleware that plays a crucial role in ensuring the security of application routes. Essentially, it enables you to create authentication or authorization logic so that only users with appropriate permissions can access specific routes.
For instance, imagine you have a route to access confidential user information such as banking or health data. With the Route Guard, you can implement a check to ensure that only authorized users can access that route, thus safeguarding such information.
To use the Route Guard in ModularBr, simply create a class that inherits from TRouteMiddleware and implement the Call method, which is a boolean class function responsible for verifying whether the user has the necessary permissions to access the route. This function can examine information such as the user type, access level, or any other relevant data for your application.
Next, add this class to the RouteModule() method of the route. This way, whenever someone tries to access that route, the class function will be executed to verify the user's permissions.
With the Route Guard, you can ensure that your routes are protected, and only authorized users will have access to sensitive information in your application.