Documentation Index
Fetch the complete documentation index at: https://mintlify.com/David9604/BackMaqagr/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Updates an existing role in the system. This endpoint is restricted to administrators only. At least one field must be provided for the update.
Admin Access Required: This endpoint requires administrator privileges. Regular users will receive a 403 Forbidden error.
Authentication
Requires JWT authentication token with admin role in the Authorization header.
Authorization: Bearer <admin_token>
Path Parameters
The ID of the role to update.
Request Body
New name for the role. Must be unique and at least 2 characters long.
New description for the role.
Status of the role.Options: active, inactive
At least one field (role_name, description, or status) must be provided.
Response
Indicates if the request was successful.
The updated role object.
Role status: “active” or “inactive”
curl -X PUT https://api.maqagr.com/api/roles/3 \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"role_name": "super_moderator",
"description": "Moderador con permisos extendidos",
"status": "active"
}'
{
"success": true,
"message": "Rol actualizado exitosamente",
"data": {
"role": {
"role_id": 3,
"role_name": "super_moderator",
"description": "Moderador con permisos extendidos",
"status": "active",
"created_at": "2024-03-11T20:00:00.000Z",
"updated_at": "2024-03-11T20:30:00.000Z"
}
}
}
Validation Rules
- At least one field must be provided for update
- role_name must be at least 2 characters if provided
- role_name must be unique if provided
- status must be either “active” or “inactive” if provided
- User must have administrator role
- Role ID must be valid
Source Code Reference
- Route:
src/routes/role.routes.js:286
- Controller:
src/controllers/roleController.js:118
- Middleware:
src/middleware/auth.middleware.js (isAdmin)