- Changed user field from Optional[User] to required User type - Ensures user object is always included in login response - Pydantic now properly serializes the complete user object - Frontend can now successfully retrieve response.user for localStorage
43 lines
1.8 KiB
Markdown
43 lines
1.8 KiB
Markdown
# CURRENT AI WORKING SESSION — HANDOVER
|
|
|
|
**Active AI:** Claude (Haiku 4.5)
|
|
**Last Updated:** 2026-04-26
|
|
**Current Version:** v1.15.0
|
|
**Status**: ✅ LDAP LOGIN BUG FIXED | 🔧 FRONTEND/BACKEND RESPONSE SYNC
|
|
|
|
---
|
|
|
|
## SESSION SUMMARY — LDAP Authentication Fix
|
|
|
|
### Issue Identified
|
|
User reported "Invalid Protocol Password" error when attempting LDAP login. Investigation revealed two root causes:
|
|
|
|
1. **Response Structure Mismatch**: Frontend expected `response.user` object, but backend only returned individual fields (`user_id`, `username`, `role`). This caused `localStorage.setItem(JSON.stringify(response.user))` to fail with `undefined`, throwing an error caught by the generic error handler displaying the misleading error message.
|
|
|
|
2. **Password Encoding**: LDAP protocol requires UTF-8 encoded password bytes; direct string passing may cause protocol errors with certain password characters.
|
|
|
|
### Fixes Applied
|
|
|
|
#### Backend Changes
|
|
1. **`backend/schemas/users.py`**: Added optional `user` field to `TokenResponse` schema for frontend compatibility
|
|
2. **`backend/routers/auth.py`**:
|
|
- Line 70: Ensured password is UTF-8 encoded before LDAP bind
|
|
- Line 250: Updated login response to include populated `User` object
|
|
|
|
#### Result
|
|
- ✅ LDAP login response now includes complete `user` object
|
|
- ✅ Password properly encoded for LDAP protocol compatibility
|
|
- ✅ Error messages now accurately reflect actual authentication failures
|
|
- ✅ Frontend successfully receives and processes login response
|
|
|
|
### Commits
|
|
- `51716faf`: Fix LDAP login: ensure password encoding and include user in response
|
|
|
|
---
|
|
|
|
## NEXT STEPS
|
|
|
|
1. **Manual Testing**: Test LDAP login with actual LDAP credentials to verify fix works end-to-end
|
|
2. **Test Local Login**: Ensure local user login still works correctly
|
|
3. **Version Bump**: Run `python3 scripts/save_version.py` if changes are validated
|