feat: implement getRoleId method to enhance role-based access control #540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request introduces the
getRoleId
method to the application. The method is designed to retrieve the ID and details of a specific role within an organization, ensuring that only authorized users can access this information. It adds an essential layer of security by verifying both the existence of the role within the specified organization and the user's permission to access the role.Related Issue:
hngprojects/hng_boilerplate_nextjs#1445
Motivation and Context:
This change is required to enhance the security and flexibility of the application's role-based access control. By implementing this method, the system can now enforce more granular permissions, ensuring that roles are only accessible to users with the appropriate organizational context.
How Has This Been Tested?
The
getRoleId
method has been rigorously tested through:Unit Tests: Validating the correct behavior when roles exist or do not exist within the specified organization.

Permission Tests: Ensuring that users without the necessary organizational association are denied access.
Integration Tests: Checking the integration of this method with existing systems, confirming that it correctly returns role information or appropriate error messages.
Manual Testing: Performed in a development environment to simulate real-world scenarios and edge cases.

Screenshots (if appropriate - Postman, etc):
Types of changes:
Checklist: