Shared API Routes

This section documents API endpoints that are accessible to all authenticated users or are public.

POST /auth/login

Description: Route for all user login.

Request:
POST http://localhost:8080/api/v1/auth/login

Request Body:
{
    "email": "e...@yahoo.com",
    "password": "e...@2025"
}

Response:
{
    "access_token": "eyJhbGciO...",
    "refresh_token": "eyJh...",
    "role": "admin"
}

POST /auth/reset-password

Description: Resetting password for all users.
Note: You must include credentials: include when sending the request.

Request:
POST http://localhost:8080/api/v1/auth/reset-password

Request Body:
{
    "email": "e...@yahoo.com",
    "new_password": "e...@2025?"
}

Response:
{
    "message": "Password reset successfully. Check your email."
}

GET /auth/logout

Description: Logout route for all users.
Note: You must include credentials: include when sending the request.

Request:
GET http://localhost:8080/api/v1/auth/logout

Response:
{
    "message": "Successfully logged out"
}

GET /auth/me

Description: Get current user profile (response below is for lecturer login).
Note: You must include credentials: include when sending the request.

Request:
GET http://localhost:8080/api/v1/auth/me

Response (Lecturer):
{
    "courses": [
        {
            "code": "CS",
            "department": "Computer Science",
            "id": "7d1360db-d1f3-40c1-9f05-6ab64d60f281",
            "name": "Computer Science",
            "school": "CS & IT",
            "units": [
                {
                    "course_id": "7d1360db-d1f3-40c1-9f05-6ab64d60f281",
                    "id": "36ee41ed-21b0-4311-a848-6608baea6553",
                    "level": 4,
                    "semester": 1,
                    "unit_code": "CCS 4101",
                    "unit_name": "Human Computer Interaction (HCI)"
                },
                {
                    "course_id": "7d1360db-d1f3-40c1-9f05-6ab64d60f281",
                    "id": "7492ca17-2fe6-4d17-9ac2-5119124a3716",
                    "level": 4,
                    "semester": 1,
                    "unit_code": "CCS 4103",
                    "unit_name": "Computer Security"
                },
                {
                    "course_id": "7d1360db-d1f3-40c1-9f05-6ab64d60f281",
                    "id": "91827bb6-2be8-4b0a-9bc0-af472aacc375",
                    "level": 4,
                    "semester": 1,
                    "unit_code": "CCS 4102",
                    "unit_name": "Machine Learning"
                }
            ]
        }
    ],
    "email": "w...@yahoo.com",
    "id": "daa64de5-44d5-435a-a156-08637dccb58a",
    "name": "George",
    "othernames": "",
    "role": "lecturer",
    "surname": "Mutuku"
}