Skip to content

fix: resolved doctor login

Rajuldev Vandana requested to merge fix/doctor-login into develop

🩺 Restrict Doctor Login to Camp-Registered Users

Overview

This MR fixes an issue where doctors who were not registered for a medical camp were still able to log in and be marked as available. This caused incorrect data in downstream flows such as specialization selection.


Problem

  • Unregistered doctors could log in from the Doctors Directory.

  • Backend was automatically creating a CampVisit record with:

    • attendance = True
    • login_time set
  • As a result:

    • These doctors appeared as available
    • Their specializations showed up in patient assignment (incorrect behavior)

Solution

Updated the update_user_attendance logic in:

app/services/medical_camp_service.py

New Behavior:

  • If a doctor attempts to log in:

    • Reject if no CampVisit record exists
    • Reject if signup = False (not registered)
  • Only allow login when:

    • CampVisit exists AND signup = True

🔐 Impact

  • Ensures only camp-registered doctors can log in
  • Prevents invalid availability states
  • Keeps specialization dropdown accurate (only registered + logged-in doctors)

🧪 Test Cases

  1. Unregistered Doctor Login

    • Attempt login without camp registration
    • Expected: Rejected with error message
  2. Registered Doctor Login

    • Register doctor → login
    • Expected: Success, status = Available
  3. Specialization Validation

    • Only registered + logged-in doctors appear in specialization dropdown

💬 Backend Response

Returns:

"Doctors must be registered for the camp before logging in."

📌 Notes

  • No changes required in frontend for enforcement (backend validation is strict)
  • Frontend can optionally disable login button for better UX

Edited by Rajuldev Vandana

Merge request reports

Loading