feat: add hasRole helper to requireRole middleware
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
25424ccb7e
commit
34cc5debf7
1 changed files with 10 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue