fix: resolved doctor login
🩺 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
CampVisitrecord with:attendance = True-
login_timeset
-
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 noCampVisitrecord exists -
❌ Reject ifsignup = False(not registered)
-
-
Only allow login when:
-
✅ CampVisitexists ANDsignup = 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
-
Unregistered Doctor Login
- Attempt login without camp registration
- Expected:
❌ Rejected with error message
-
Registered Doctor Login
- Register doctor → login
- Expected:
✅ Success, status = Available
-
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