tractatus/.gitignore
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

102 lines
1.4 KiB
Text

# Dependencies
node_modules/
# Environment variables
.env
.env.local
.env.*.local
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# MongoDB data
data/mongodb/*
!data/mongodb/.gitkeep
# Generated files
public/downloads/*.pdf
public/downloads/*.epub
public/downloads/*.docx
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
# Testing
coverage/
.nyc_output/
# Build
dist/
build/
# Temporary files
tmp/
temp/
*.tmp
# ============================================
# SECURITY: Private GitHub Protection
# ============================================
# Sensitive internal documentation (keep private, never push)
CLAUDE.md
CLAUDE.md.backup
CLAUDE_Tractatus_Maintenance_Guide.md
SESSION-HANDOFF-*.md
docs/SECURITY_AUDIT_REPORT.md
docs/FRAMEWORK_FAILURE_*.md
old*
*.backup
# Framework session state (regenerated each session)
.claude/session-state.json
.claude/token-checkpoints.json
# Secrets and credentials
*.key
*.pem
*.p12
*.pfx
secrets/
credentials/
# Database dumps and backups
dump/
backups/
*.sql
*.sql.gz
*.dump
# SSH keys (extra safety)
*.ssh/
id_rsa*
id_ed25519*
# Deployment configurations with secrets
deployment-config.json
production.json
# Temporary audit files
/tmp/*.md
# Screenshots and temporary images
Screenshot*.png
*.screenshot.png
umami-local/
ADMIN_LOGIN_INSTRUCTIONS.md
scripts/reset-admin-password.js
.admin-credentials.local
scripts/reset-admin-password.js
ADMIN_LOGIN_INSTRUCTIONS.md