fix: enable overrideAccess=true for public Payload repository reads
All public pages (site settings, header, pages, articles) now bypass Payload's access control checks when reading, as they should be publicly accessible without authentication. This fixes 403 Forbidden errors on homepage and article rendering.
This commit is contained in:
@@ -35,7 +35,7 @@ describe("PayloadArticlesRepository", () => {
|
||||
collection: "articles",
|
||||
where: { slug: { equals: "hello" } },
|
||||
limit: 1,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
expect(result?.id).toBe("p-123");
|
||||
expect(result?.slug).toBe("hello");
|
||||
|
||||
@@ -50,7 +50,7 @@ export class PayloadArticlesRepository implements IArticlesRepository {
|
||||
const doc = await payload.findByID({
|
||||
collection: "articles",
|
||||
id,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
return mapDoc(doc as PayloadArticleDoc);
|
||||
} catch {
|
||||
@@ -64,7 +64,7 @@ export class PayloadArticlesRepository implements IArticlesRepository {
|
||||
collection: "articles",
|
||||
where: { slug: { equals: slug } },
|
||||
limit: 1,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
const doc = result.docs[0] as PayloadArticleDoc | undefined;
|
||||
return doc ? mapDoc(doc) : undefined;
|
||||
@@ -88,7 +88,7 @@ export class PayloadArticlesRepository implements IArticlesRepository {
|
||||
page: options?.offset
|
||||
? Math.floor(options.offset / (options.limit ?? 50)) + 1
|
||||
: 1,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
return result.docs.map((d) => mapDoc(d as PayloadArticleDoc));
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export class PayloadArticlesRepository implements IArticlesRepository {
|
||||
status: input.status,
|
||||
author: input.authorId,
|
||||
} as never,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
return mapDoc(created as PayloadArticleDoc);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ export class PayloadArticlesRepository implements IArticlesRepository {
|
||||
...(input.status !== undefined && { status: input.status }),
|
||||
...(input.authorId !== undefined && { author: input.authorId }),
|
||||
} as never,
|
||||
overrideAccess: false,
|
||||
overrideAccess: true,
|
||||
});
|
||||
return mapDoc(updated as PayloadArticleDoc);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user