Commit graph

4 commits

Author SHA1 Message Date
jedarden
3da0c32ba3 feat: dashboard PIN change flow
- Backend: Add POST /api/auth/change-pin endpoint
  - Requires valid session; body: {old_pin, new_pin}
  - Verifies old PIN against bcrypt hash; returns 403 on mismatch
  - Hashes new PIN with bcrypt cost=12
  - Existing sessions remain valid after PIN change
  - Returns {ok:true} on success

- Dashboard: Security section in settings panel
  - Add "Security" section with Change PIN button
  - Modal form: old PIN → new PIN → confirm new PIN → Submit
  - Inline error display for incorrect current PIN (403)
  - Success toast notification on PIN change
  - Validation: 4-8 digits, numeric only, PINs must match, new ≠ old

- Tests: Add comprehensive tests for change PIN endpoint
  - Success case: old PIN verified, new PIN works
  - Wrong old PIN: returns 403, original PIN still works
  - Unauthenticated: returns 401
  - Invalid new PIN: validation for length, digits, etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 08:05:35 -04:00
jedarden
22b745f274 feat: webhook action firing & fault tolerance for automations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 20:29:53 -04:00
jedarden
e83b54a9ec feat: implement dashboard PIN authentication and session management
Backend (mothership/internal/auth/):
- SQLite auth table with pin_bcrypt and install_secret (singleton row)
- GET /api/auth/status — return {pin_configured: bool}
- POST /api/auth/setup — sets PIN (bcrypt cost 12) on first run only
- POST /api/auth/login — verifies PIN, issues session cookie (7-day expiry)
- POST /api/auth/logout — clears cookie and deletes session from SQLite
- Session middleware: all /api/* and /ws/* require valid session
- Rolling window: extends session by 7 days if within 24h of expiry
- Install secret generation for node token derivation

Dashboard (dashboard/js/auth.js):
- On load: GET /api/auth/status check
- First-run setup page: enter PIN + confirm PIN → POST /api/auth/setup → reload
- Login page: shown on 401; PIN entry → POST /api/auth/login → reload
- Logout button in settings panel → POST /api/auth/logout → redirect

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:16:04 -04:00
jedarden
c424104582 feat: build dashboard panel/modal/sidebar UI framework
Implemented a comprehensive panel framework for the Spaxel dashboard to
support Phase 6-9 UI work (automation builder, timeline, explainability,
settings, notifications, presence predictions).

- Panel System (dashboard/js/panels.js):
  - Slide-in sidebar (right, 360px) with close button and title
  - Modal overlay (centered, 600px wide) for forms and wizards
  - Toast notification stack (bottom-right) with type variants
  - Panel registry: panels can be opened by name from anywhere

- Route/Mode Navigation (dashboard/js/router.js):
  - Hash-based routing: #live (default), #timeline, #automations, #settings
  - Mode toggle bar in header with active state styling
  - Active mode persisted across page refresh (localStorage)

- State Management (dashboard/js/state.js):
  - Central app state object (nodes, blobs, zones, links, alerts, events)
  - Subscribe/notify pattern for reactive component updates
  - Convenience methods for common operations (updateNode, addEvent, etc.)

- Settings Panel (dashboard/js/settings-panel.js):
  - Motion threshold slider (deltaRMS threshold)
  - Fusion rate selection (5/10/20 Hz)
  - Grid cell size and Fresnel decay rate controls
  - Subcarrier count and baseline time constant settings
  - Notification channel config (Ntfy URL/token, Pushover keys)
  - System info display (version, uptime, detection quality, node count)

- Updated index.html with:
  - CSS/JS includes for panel framework
  - Settings button in status bar

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 10:04:40 -04:00