Fix TokenResponse schema: make user field non-optional and properly typed
- 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
This commit is contained in:
@@ -1,36 +1,42 @@
|
||||
# CURRENT AI WORKING SESSION — HANDOVER
|
||||
|
||||
**Active AI:** Gemini CLI (Antigravity)
|
||||
**Active AI:** Claude (Haiku 4.5)
|
||||
**Last Updated:** 2026-04-26
|
||||
**Current Version:** v1.15.0
|
||||
**Status**: ✅ DOCUMENTATION CLEANUP & RESTRUCTURING COMPLETE | 💾 STAGED IN docs-cleanup BRANCH
|
||||
**Status**: ✅ LDAP LOGIN BUG FIXED | 🔧 FRONTEND/BACKEND RESPONSE SYNC
|
||||
|
||||
---
|
||||
|
||||
## SESSION SUMMARY — Documentation Overhaul
|
||||
## SESSION SUMMARY — LDAP Authentication Fix
|
||||
|
||||
### 1. Architectural Restructuring
|
||||
- **Consolidated Design System**: Created `DESIGN_SYSTEM.md` as the Single Source of Truth for all UI/UX (Colors, Typography, Spacing, Shapes).
|
||||
- **Consolidated Coding Standards**: Created `CODING_STANDARDS.md` merging backend/frontend rules, security, and testing targets.
|
||||
- **Refined AI Mandates**: Renamed `AI_RULES.md` to `AI_MANDATES.md`, focusing on behavioral rules and handover protocols.
|
||||
- **Improved Technical Reference**: Renamed `PROJECT_ARCHITECTURE.md` to `ARCHITECTURE.md`, focusing on high-level system logic.
|
||||
- **Fixed Roadmap**: Resolved merge conflicts in `dev_docs/PLAN.md` and moved to `ROADMAP.md` in root.
|
||||
### Issue Identified
|
||||
User reported "Invalid Protocol Password" error when attempting LDAP login. Investigation revealed two root causes:
|
||||
|
||||
### 2. Information Cleanup & Archiving
|
||||
- **Archived Legacy Files**: Moved 10+ redundant or outdated audit/review/plan files to `dev_docs/archive/`.
|
||||
- **Eliminated Duplication**: Deleted `AI_RULES.md`, `PROJECT_ARCHITECTURE.md`, `DESIGN_COLOR_RULES.md`, and redundant plans.
|
||||
- **Cleaned Entry Points**: Updated `README.md`, `CLAUDE.md`, and `GEMINI.md` to point to the new, functional documentation structure.
|
||||
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.
|
||||
|
||||
### 3. Verification & Compliance
|
||||
- **Design Alignment**: Ensured "NO BOLD" and "NO UPPERCASE" mandates are documented as absolute law.
|
||||
- **SSOT Integrity**: Established clear hierarchies for documentation (End-User vs Internal).
|
||||
- **Git Status**: All changes staged in new branch `docs-cleanup`.
|
||||
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. **Review Documentation**: Verify the new structure in the `docs-cleanup` branch.
|
||||
2. **Commit Changes**: If satisfied, commit the staged changes to the branch.
|
||||
3. **Merge to dev**: Merge `docs-cleanup` into the main `dev` branch.
|
||||
4. **Version Bump**: Run `python3 scripts/save_version.py` to finalize the v1.15.0 documentation milestone.
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user