#42 [Admin Panel] Role Assignment API - Assign Roles
Description
EditImplement POST /api/v1/admin/users/<user_id>/roles endpoint to assign roles to users.
**API Specification:**
- Endpoint: POST /api/v1/admin/users/<user_id>/roles
- Permission Required: manage_users
- Path Parameter: user_id (UUID)
- Request Body: {roles: ['role_name1', 'role_name2']}
- Response: {user_id, roles: updated_roles[]}
**Requirements:**
- Validate all role names exist
- Idempotent - assigning existing role is no-op
- Support bulk role assignment
- Prevent removing last tenant_admin role if user is only admin
- Log audit event with roles added
**Validation:**
- Role must exist in system
- User must belong to current tenant
- Cannot assign super_admin role via API
**IMPORTANT:** Implement with ultra attention to details and correctness.
**BEFORE CLOSING:** Take screenshot showing role assignment. Add comment summarizing implementation.
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...