fix: allow groomer/receptionist roles to read staff records #151

Closed
groombook-engineer[bot] wants to merge 24 commits from fix/gro-162-groomer-staff-rbac into main
2 changed files with 3 additions and 3 deletions
Showing only changes of commit d3c88ea9fb - Show all commits
+1 -1
View File
@@ -168,7 +168,7 @@ describe("resolveStaffMiddleware", () => {
});
const res = await app.request("/test", {
headers: { "X-Dev-User-Id": GROOMER.userId! },
headers: { "X-Dev-User-Id": GROOMER.id },
});
expect(res.status).toBe(200);
expect(capturedStaff!.role).toBe("groomer");
+2 -2
View File
@@ -40,11 +40,11 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
await next();
return;
}
// Treat X-Dev-User-Id as the Better-Auth user ID
// 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.userId, devUserId));
.where(eq(staff.id, devUserId));
if (!row) {
return c.json(
{ error: "Forbidden: no staff record found for X-Dev-User-Id" },