Fix 404 error when saving user preferences
Routes using withAuth were creating new unauthenticated PocketBase clients, causing 404 errors when trying to update records. Modified withAuth to pass the authenticated pb client to handlers so they can use it for database operations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,7 +113,12 @@ describe("withAuth", () => {
|
||||
const response = await wrappedHandler(mockRequest);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(handler).toHaveBeenCalledWith(mockRequest, mockUser, undefined);
|
||||
expect(handler).toHaveBeenCalledWith(
|
||||
mockRequest,
|
||||
mockUser,
|
||||
mockPbClient,
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it("loads auth from cookies before checking authentication", async () => {
|
||||
@@ -159,7 +164,7 @@ describe("withAuth", () => {
|
||||
|
||||
await wrappedHandler(mockRequest, { params: mockParams });
|
||||
|
||||
expect(handler).toHaveBeenCalledWith(mockRequest, mockUser, {
|
||||
expect(handler).toHaveBeenCalledWith(mockRequest, mockUser, mockPbClient, {
|
||||
params: mockParams,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user