feat: add hasRole helper to requireRole middleware
Some checks are pending
Docker Test / test (push) Waiting to run

This commit is contained in:
J.A.R.V.I.S. 2026-03-20 02:06:46 +00:00
parent 25424ccb7e
commit 34cc5debf7

View file

@ -18,3 +18,13 @@ export default function requireRole(allowedRoles) {
next();
};
}
/**
* Helper function to check if a user has a specific role.
* @param {string} userRole - The role of the user.
* @param {string[]} requiredRoles - Array of roles required.
* @returns {boolean} True if the user has at least one of the required roles.
*/
export function hasRole(userRole, requiredRoles) {
return requiredRoles.includes(userRole);
}