-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Labels
Description
Description
Add an endpoint to allow super admin and admin users to get all the reports been reported by users.
Acceptance Criteria
- It should be an authenticated endpoint, accessible only by admin and super admin.
- It should be a GET request at /api/v1/reports.
- The request should require admin and super admin authorization.
- The system should get all reports from the database.
- The response should return a structured JSON format with a status code 200
- If the requesting user is unauthorized, the request should return an appropriate error message.
Purpose
To allow admin and super admins to efficiently get all reports, ensuring better content management and report review.
Requirements
- Develop server-side logic to get all the reports from the report table in the database.
- Ensure the endpoint is secured and accessible only to admins and super admins.
- Write unit tests to validate the functionality of the endpoint.
Expected Outcome
Admins and Super admins should be able to get reports in one request, ensuring proper authorization and review of reports.
Tasks
- Create an endpoint (GET: /api/v1/report) to get all reports.
- Implement authentication and authorization to restrict access to Admins and super admins.
- Develop logic to fetch all the reports from the database.
- Ensure proper error handling for unauthorized access.
- Write comprehensive unit tests for the endpoint.
Example Request
curl -X DELETE {rootdomain}/api/v1/report \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" Response [Success]
{
"status_code": 200,
"data": [
{
"id": "report_id",
"reported_by": "userId1",
"reported_user": "userId2",
"reason": "reason of been reported",
"status": "pending",
"created_at": "2025-02-21"
},
{
"id": "report_id",
"reported_by": "userId3",
"reported_user": "userId4",
"reason": "reason of been reported",
"status": "pending",
"created_at": "2025-02-21"
},
]
} Response [Errors]
- Unauthorized Request
{
"status_code": 403,
"error": "Forbidden. Super admin access required."
} Testing
Write unit tests to ensure all squeeze pages are deleted.
Test proper authentication and authorization mechanisms.
Test edge cases, such as attempting fetching as a non-super admin.