Skip to content

Refactored the authorization-based role middlewares

Hikmat Bangash requested to merge development into main

This commit introduces significant refactoring to the authorization-based role middlewares. The code has been streamlined and improved for better readability and maintainability. The previous implementation using Promises has been replaced with synchronous operations, resulting in cleaner and more efficient code.

The verifyToken function has been modified to handle token verification synchronously using the jsonwebtoken library. Additionally, the verifyUser and verifyAdmin functions now make use of the refactored verifyToken function and feature a more concise and logical flow for handling authorization based on user roles.

By refactoring these middlewares, we ensure that the authorization logic is more straightforward, reducing the likelihood of errors and improving the overall code quality.

Merge request reports