fix(auth): dev login 403 — resolve staff by id, not oidcSub (GRO-150)
The DevLoginSelector stores the staff database id in localStorage and sends it as X-Dev-User-Id. The resolveStaffMiddleware incorrectly looked up staff by oidcSub instead of id, causing all API endpoints to return 403 for every user in dev mode. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -41,11 +41,11 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
|
||||
await next();
|
||||
return;
|
||||
}
|
||||
// Treat X-Dev-User-Id as the oidcSub
|
||||
// Treat X-Dev-User-Id as the staff database id (the frontend stores staff.id)
|
||||
const [row] = await db
|
||||
.select()
|
||||
.from(staff)
|
||||
.where(eq(staff.oidcSub, devUserId));
|
||||
.where(eq(staff.id, devUserId));
|
||||
if (!row) {
|
||||
return c.json(
|
||||
{ error: "Forbidden: no staff record found for X-Dev-User-Id" },
|
||||
|
||||
Reference in New Issue
Block a user