screentinker/server
ScreenTinker 772ead28a2 Fix reset-admin.js: honor recovery token in requireAuth
scripts/reset-admin.js signed a JWT with a synthetic id ("recovery-XXX")
and instructed the operator to paste it into localStorage. But the
requireAuth middleware always SELECTs the user row by id, so every
authed API call under the recovery token returned 401 "User not found"
and the recovery flow was effectively dead.

Fix:
- reset-admin.js now sets a `recovery: true` claim on the JWT.
- requireAuth / optionalAuth short-circuit the DB lookup when
  decoded.recovery === true and synthesize a req.user record in
  memory (role: admin, plan_id: enterprise). The synthetic user is
  never persisted, so FK-constrained writes that expect a real
  user (creating devices, etc.) will still fail — which is fine,
  recovery is only meant to let the operator reset a password or
  create a fresh admin via the Settings UI.

Security: a recovery token still requires the jwtSecret to sign,
so only someone with filesystem access to the server can mint one.
Token TTL remains 1h.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 19:08:49 -05:00
..
db Fix startup crash on existing DB: defer group_id index to migration 2026-04-16 07:59:49 -05:00
middleware Fix reset-admin.js: honor recovery token in requireAuth 2026-04-21 19:08:49 -05:00
player Add group-level scheduling, group playlist assignment, and persist audio unlock 2026-04-15 20:22:42 -05:00
routes Add group-level scheduling, group playlist assignment, and persist audio unlock 2026-04-15 20:22:42 -05:00
services Add group-level scheduling, group playlist assignment, and persist audio unlock 2026-04-15 20:22:42 -05:00
ws Fix broken service worker + device auth rejection on playlist refresh 2026-04-13 22:18:08 -05:00
config.js Initial open source release 2026-04-08 12:14:53 -05:00
package-lock.json Initial open source release 2026-04-08 12:14:53 -05:00
package.json Initial open source release 2026-04-08 12:14:53 -05:00
server.js Auto-reload web player when server code changes 2026-04-13 22:44:47 -05:00