Function get_me

Source
pub async fn get_me(
    __arg0: State<AppState>,
    __arg1: AuthUser,
) -> impl IntoResponse
Expand description

GET /api/auth/me

Returns the authenticated user’s profile along with their module roles. Requires a valid bearer token in the Authorization header.

§Response: 200 OK

{
  "success": true,
  "message": "User data retrieved successfully",
  "data": {
    "id": 42,
    "email": "[email protected]",
    "username": null,
    "admin": true,
    "created_at": "2024-11-10T12:34:56Z",
    "updated_at": "2025-06-18T10:00:00Z",
    "modules": [
      {
        "module_id": 101,
        "module_code": "CS101",
        "module_year": 2025,
        "module_description": "Intro to Computer Science",
        "module_credits": 15,
        "module_created_at": "2023-11-01T08:00:00Z",
        "module_updated_at": "2025-02-20T14:22:00Z",
        "role": "Lecturer"
      },
      {
        "module_id": 202,
        "module_code": "CS202",
        "module_year": 2025,
        "module_description": "Data Structures",
        "module_credits": 20,
        "module_created_at": "2023-11-05T09:00:00Z",
        "module_updated_at": "2025-03-10T13:45:00Z",
        "role": "Admin"
      }
    ]
  }
}

§Error Responses

  • 403 Forbidden – Missing or invalid token
  • 404 Not Found – User not found
  • 500 Internal Server Error – Database failure