tractatus/public
TheFlow 4e4401a117 fix(auth): resolve admin login - token sanitization and missing password field
SUMMARY:
Fixed admin login failures caused by two issues:
1. Response sanitization middleware stripping auth tokens
2. Admin users missing password field in database

ROOT CAUSE ANALYSIS:
- sanitizeResponseData middleware removed ALL fields named 'token'
- This included authentication tokens that SHOULD be sent to clients
- Admin user records created without proper password field
- User.authenticate() failed on bcrypt.compare() with undefined password

FIXES:
1. Changed auth response field from 'token' to 'accessToken'
   - Avoids overly aggressive sanitization
   - More semantically correct (it's specifically an access token)
   - Frontend updated to use data.accessToken

2. Created fix-admin-user.js script
   - Properly creates admin user via User.create()
   - Ensures password field is bcrypt hashed
   - Deletes old malformed user records

3. Updated login.js auto-fill for correct dev email
   - Changed from admin@tractatus.local to admin@agenticgovernance.digital

TESTING:
- Local login now returns accessToken (308 char JWT)
- User object returned with proper ID serialization
- Auth flow: POST /api/auth/login → returns accessToken + user
- Ready for production deployment

FILES:
- src/controllers/auth.controller.js: Use accessToken field
- public/js/admin/login.js: Store data.accessToken, update default email
- scripts/fix-admin-user.js: Admin user creation/fix utility

NEXT STEPS:
1. Deploy to production
2. Run: node scripts/fix-admin-user.js admin@agenticgovernance.digital <password>
3. Test admin login at /admin/login.html

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 21:13:42 +13:00
..
.well-known security: comprehensive security audit and hardening 2025-10-10 05:34:40 +13:00
about style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
admin style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
css feat(phase3): add data visualizations for context pressure and activity timeline 2025-10-19 20:49:26 +13:00
demos feat(demos): create interactive pluralistic deliberation demo 2025-10-19 22:03:25 +13:00
docs docs(planning): add website improvement priorities and audit results 2025-10-20 17:18:50 +13:00
downloads docs: regenerate PDFs and update documentation metadata 2025-10-14 10:53:48 +13:00
fonts fix(csp): clean all public-facing pages - 75 violations fixed (66%) 2025-10-19 13:17:50 +13:00
images feat(interactive): add clickable central core and improve desktop layout 2025-10-19 16:37:27 +13:00
js fix(auth): resolve admin login - token sanitization and missing password field 2025-10-20 21:13:42 +13:00
koha fix(a11y): improve text contrast on koha transparency page 2025-10-19 14:07:38 +13:00
locales feat(content): enhance About page and publish scaling roadmap blog article 2025-10-20 20:29:58 +13:00
about.html feat(content): enhance About page and publish scaling roadmap blog article 2025-10-20 20:29:58 +13:00
api-reference.html style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
architecture.html fix(ui): improve pressure monitor visibility and add timeline synchronization 2025-10-20 17:18:13 +13:00
blog-post.html style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
blog.html style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
case-submission.html fix(csp): clean all public-facing pages - 75 violations fixed (66%) 2025-10-19 13:17:50 +13:00
check-version.html style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
docs-viewer.html feat(phase3): add code snippet copy buttons and collapsible TOC 2025-10-19 15:27:33 +13:00
docs.html perf(docs): improve LCP with deferred scripts and font preloading 2025-10-19 21:22:05 +13:00
faq.html fix(accessibility): improve contrast ratios and add meta description 2025-10-19 20:55:04 +13:00
favicon-new.svg fix(csp): clean all public-facing pages - 75 violations fixed (66%) 2025-10-19 13:17:50 +13:00
favicon.ico feat: implement Rule Manager and Project Manager admin systems 2025-10-11 17:16:51 +13:00
favicon.svg feat: comprehensive documentation improvements and GitHub integration 2025-10-09 14:33:14 +13:00
implementer.html fix(contact): replace personal email with research@agenticgovernance.digital 2025-10-19 21:00:38 +13:00
index.html fix(i18n): add German and French translations for performance evidence section 2025-10-19 21:59:59 +13:00
koha.html fix(accessibility): improve contrast ratios and add meta description 2025-10-19 20:55:04 +13:00
leader.html feat(phase3): implement smooth page transitions with fade effect 2025-10-19 20:44:25 +13:00
manifest.json style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
media-inquiry.html fix(csp): clean all public-facing pages - 75 violations fixed (66%) 2025-10-19 13:17:50 +13:00
media-triage-transparency.html style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
privacy.html fix(i18n): add cache-busting version strings to privacy page scripts 2025-10-19 14:56:25 +13:00
researcher.html feat(phase3): implement smooth page transitions with fade effect 2025-10-19 20:44:25 +13:00
service-worker.js style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00
test-pressure-chart.html fix(ui): improve pressure monitor visibility and add timeline synchronization 2025-10-20 17:18:13 +13:00
version.json style(ui): update theme, branding, and GitHub repository links 2025-10-19 12:48:29 +13:00