fix(auth): add email-based staff auto-linking in resolveStaffMiddleware #295

Merged
the-dogfather-cto[bot] merged 1 commits from fix/gro-665-staff-auto-link into main 2026-04-15 05:50:59 +00:00

1 Commits

Author SHA1 Message Date
Flea Flicker a222bd4542 fix(auth): add email-based staff auto-linking in resolveStaffMiddleware
Add email-based auto-linking fallback so staff records without a userId are
automatically linked on first authenticated request. This fixes a UAT blocker
where all authenticated API routes returned HTTP 403 after login because
Better-Auth user IDs don't match seed-created staff records.

Fallback chain:
1. userId match (existing fast path)
2. oidcSub match (legacy records)
3. email match + auto-link (new)
2026-04-15 05:39:34 +00:00