Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Implement Endpoint for Creating Roles (OS-001) #104

Closed
wants to merge 1 commit into from

Conversation

urizennnn
Copy link
Contributor

PR: Implement Endpoint for Creating Roles (OS-001)

This PR implements an endpoint for creating roles within an organization, addressing the requirements specified in OS-001.

Changes

  • Created a new RoleController with a CreateRole method
  • Implemented the POST /api/v1/roles endpoint
  • Updated database schema to support role creation
  • Added input validation and error handling
  • Implemented authentication and authorization checks

New Endpoint

POST /api/v1/roles

Request Body

json
{
"role_name": "String",
"organization_id": "String",
"permission_ids": ["String", "String", ...]
}

Success Response (201 Created)

json
{
"message": "Role created successfully",
"status_code": 201
}

Error Response (400 Bad Request, 401 Unauthorized, 403 Forbidden, 500 Internal Server Error)

json
{
"error": "Error message",
"status_code": 400
}

Implementation Details

  • Used GORM for database operations
  • Implemented transaction to ensure atomicity of role creation and permission assignment
  • Added middleware for authentication and authorization
  • Used UUID for generating unique role IDs

Testing

  • Added unit tests for the CreateRole method
  • Implemented integration tests for the role creation process
  • Tested various scenarios including successful creation, invalid input, and error conditions

Security Measures

  • Ensured only authenticated admins and super admins can access the endpoint
  • Implemented input validation to prevent injection attacks
  • Used HTTPS for secure data transmission (to be configured in deployment)

To-Do Before Merging

  • Review and update API documentation
  • Perform thorough testing in staging environment
  • Update relevant parts of the codebase to use the new role structure

How to Test

  1. Ensure you have admin or super admin privileges
  2. Send a POST request to /api/v1/roles with the required payload
  3. Verify the response and check the database for the newly created role

Please review and do not let me know if any changes or additional information is needed.

@urizennnn
Copy link
Contributor Author

These are not my tests failing

@urizennnn urizennnn changed the title chore:re adding role creation PR: Implement Endpoint for Creating Roles (OS-001) Jul 22, 2024
@urizennnn urizennnn closed this Jul 23, 2024
@urizennnn urizennnn deleted the urizen branch July 24, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant