All checks were successful
CI / skip-ci-check (push) Successful in 1m25s
CI / lint-and-type-check (push) Successful in 1m50s
CI / test (push) Successful in 1m54s
CI / build (push) Successful in 1m54s
CI / secret-scanning (push) Successful in 1m26s
CI / dependency-scan (push) Successful in 1m31s
CI / sast-scan (push) Successful in 2m34s
CI / workflow-summary (push) Successful in 1m23s
# Fix authentication issues and improve developer experience ## Summary This MR fixes critical authentication issues that prevented login on localhost and improves the developer experience with consolidated rebuild scripts and a working help modal keyboard shortcut. ## Problems Fixed ### 1. Authentication Issues - **UntrustedHost Error**: NextAuth v5 was rejecting localhost requests with "UntrustedHost: Host must be trusted" error - **Cookie Prefix Errors**: Cookies were being set with `__Host-` and `__Secure-` prefixes on HTTP (localhost), causing browser rejection - **MissingCSRF Error**: CSRF token cookies were not being set correctly due to cookie configuration issues ### 2. Help Modal Keyboard Shortcut - **Shift+? not working**: The help modal keyboard shortcut was not detecting the question mark key correctly ### 3. Developer Experience - **Multiple rebuild scripts**: Had several overlapping rebuild scripts that were confusing - **Unused code**: Removed unused `useSecureCookies` variable and misleading comments ## Changes Made ### Authentication Fixes (`lib/auth.ts`) - Set `trustHost: true` to fix UntrustedHost error (required for NextAuth v5) - Added explicit cookie configuration for HTTP (localhost) to prevent prefix errors: - Cookies use `secure: false` for HTTP - Cookie names without prefixes for HTTP - Let Auth.js defaults handle HTTPS (with prefixes and Secure flag) - Removed unused `useSecureCookies` variable - Simplified debug logging ### Help Modal Fix (`components/HelpModal.tsx`) - Fixed keyboard shortcut detection to properly handle Shift+? (Shift+/) - Updated help text to show correct shortcut (Shift+? instead of Ctrl+?) ### Developer Scripts - **Consolidated rebuild scripts**: Merged `CLEAN_REBUILD.sh`, `FIX_AND_RESTART.sh`, and `start-server.sh` into single `rebuild.sh` - **Added REBUILD.md**: Documentation for rebuild process - Removed redundant script files ### Code Cleanup - Removed unused `useSecureCookies` variable from `lib/auth.ts` - Removed misleading comment from `app/api/auth/[...nextauth]/route.ts` - Cleaned up verbose debug logging ## Technical Details ### Cookie Configuration The fix works by explicitly configuring cookies for HTTP environments: - **HTTP (localhost)**: Cookies without prefixes, `secure: false` - **HTTPS (production)**: Let Auth.js defaults handle (prefixes + Secure flag) This prevents NextAuth v5 from auto-detecting HTTPS from proxy headers and incorrectly adding cookie prefixes. ### Keyboard Shortcut The question mark key requires Shift+/ on most keyboards. The fix now properly detects: - `event.shiftKey && event.key === "/"` - `event.key === "?"` (fallback) - `event.code === "Slash" && event.shiftKey` (additional fallback) ## Testing - ✅ Login works on localhost (http://localhost:3000) - ✅ No cookie prefix errors in browser console - ✅ No UntrustedHost errors in server logs - ✅ Help modal opens/closes with Shift+? - ✅ Rebuild script works in both dev and prod modes ## Files Changed ### Modified - `lib/auth.ts` - Authentication configuration fixes - `components/HelpModal.tsx` - Keyboard shortcut fix - `app/api/auth/[...nextauth]/route.ts` - Removed misleading comment ### Added - `rebuild.sh` - Consolidated rebuild script - `REBUILD.md` - Rebuild documentation ## Migration Notes No database migrations or environment variable changes required. The fix works with existing configuration. ## Related Issues Fixes authentication issues preventing local development and testing. Reviewed-on: #5
93 lines
3.0 KiB
Bash
Executable File
93 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Watch user activity logs in real-time
|
|
<<<<<<< HEAD
|
|
#
|
|
# This script monitors logs for MirrorMatch activity.
|
|
# It can watch systemd journal logs OR application log files.
|
|
#
|
|
# Usage: ./watch-activity.sh [logfile]
|
|
# - No argument: Try systemd journal (requires systemd service)
|
|
# - With argument: Watch specified log file (e.g., ./watch-activity.sh /tmp/mirrormatch-server.log)
|
|
#
|
|
# For local development:
|
|
# - If running via rebuild.sh: ./watch-activity.sh /tmp/mirrormatch-server.log
|
|
# - If running via npm run dev: ./watch-activity.sh app.log (if you redirect output)
|
|
# - If running as systemd service: ./watch-activity.sh (uses journalctl)
|
|
|
|
LOG_FILE="${1:-}"
|
|
=======
|
|
# Usage: ./watch-activity.sh
|
|
>>>>>>> gitea/main
|
|
|
|
echo "Watching user activity logs..."
|
|
echo "Press Ctrl+C to stop"
|
|
echo ""
|
|
|
|
<<<<<<< HEAD
|
|
if [ -n "$LOG_FILE" ]; then
|
|
# Watch log file
|
|
if [ ! -f "$LOG_FILE" ]; then
|
|
echo "⚠ Warning: Log file '$LOG_FILE' does not exist yet."
|
|
echo " Waiting for it to be created (will wait up to 30 seconds)..."
|
|
echo ""
|
|
# Wait for file to be created
|
|
for i in {1..30}; do
|
|
if [ -f "$LOG_FILE" ]; then
|
|
echo "✓ Log file created"
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
if [ ! -f "$LOG_FILE" ]; then
|
|
echo "❌ Log file still doesn't exist after 30 seconds"
|
|
echo " Make sure the server is running: ./rebuild.sh prod"
|
|
exit 1
|
|
fi
|
|
fi
|
|
tail -f "$LOG_FILE" 2>/dev/null | grep -E "\[ACTIVITY\]|\[PHOTO_UPLOAD\]|\[GUESS_SUBMIT\]|Activity:|INFO.*Activity:" || {
|
|
echo "⚠ No activity logs found. Make sure:"
|
|
echo " 1. Server is running"
|
|
echo " 2. LOG_LEVEL is set to INFO or DEBUG"
|
|
echo " 3. Users are actually using the site"
|
|
}
|
|
elif systemctl is-active --quiet app-backend 2>/dev/null; then
|
|
# Use systemd journal if service is active
|
|
echo "Using systemd journal (app-backend service)"
|
|
echo ""
|
|
sudo journalctl -u app-backend -f | grep -E "\[ACTIVITY\]|\[PHOTO_UPLOAD\]|\[GUESS_SUBMIT\]|Activity:|INFO.*Activity:"
|
|
else
|
|
# Try common log file locations
|
|
echo "Systemd service not found. Trying common log file locations..."
|
|
echo ""
|
|
|
|
LOG_FILES=(
|
|
"/tmp/mirrormatch-server.log"
|
|
"app.log"
|
|
"./app.log"
|
|
"/var/log/mirrormatch/app.log"
|
|
)
|
|
|
|
FOUND=false
|
|
for log in "${LOG_FILES[@]}"; do
|
|
if [ -f "$log" ]; then
|
|
echo "Found log file: $log"
|
|
echo ""
|
|
tail -f "$log" | grep -E "\[ACTIVITY\]|\[PHOTO_UPLOAD\]|\[GUESS_SUBMIT\]|Activity:|INFO.*Activity:"
|
|
FOUND=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ "$FOUND" = false ]; then
|
|
echo "❌ No log file found. Options:"
|
|
echo " 1. Specify log file: ./watch-activity.sh /path/to/logfile"
|
|
echo " 2. If using rebuild.sh, logs go to: /tmp/mirrormatch-server.log"
|
|
echo " 3. If using systemd, ensure app-backend service is running"
|
|
exit 1
|
|
fi
|
|
fi
|
|
=======
|
|
# Watch for activity logs (ACTIVITY, PHOTO_UPLOAD, GUESS_SUBMIT)
|
|
sudo journalctl -u app-backend -f | grep -E "\[ACTIVITY\]|\[PHOTO_UPLOAD\]|\[GUESS_SUBMIT\]"
|
|
>>>>>>> gitea/main
|