mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
fix(search): admit the search POST at read level through a declared, frozen readOverPost
This commit is contained in:
1 parent
1bf6108b37
commit
7ee72d0161
5 files changed
+83
-3
No files matched your search
@@ -111,7 +111,10 @@ beforeEach(() => {
|
||||
describe("POST /api/search", () => {
|
||||
it("admits the whole record only, at read", async () => {
|
||||
await handler(request("q=schulter"));
|
||||
expect(mocks.requireRecordAuth).toHaveBeenCalledWith("read", "record");
|
||||
// A POST that only reads, declared as such.
|
||||
expect(mocks.requireRecordAuth).toHaveBeenCalledWith("read", "record", {
|
||||
readOverPost: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("propagates a refused admission without searching", async () => {
|
||||
|
||||
@@ -56,7 +56,11 @@ function displayLocale(value: string | null | undefined): Locale {
|
||||
}
|
||||
|
||||
export const POST = apiHandler(async (request: NextRequest) => {
|
||||
const { user, actor, grantId } = await requireRecordAuth("read", "record");
|
||||
// A POST that only reads: the query rides the body to stay out of URLs, and
|
||||
// a read grant on the whole record is what it needs, as it was over GET.
|
||||
const { user, actor, grantId } = await requireRecordAuth("read", "record", {
|
||||
readOverPost: true,
|
||||
});
|
||||
|
||||
const rl = await checkRateLimit(
|
||||
`search:${actor.id}`,
|
||||
|
||||
Reference in new issue
Block a user