fix: join collection read access (#9930)
Respect read access control through the join field collections for GraphQL and admin UI fixes #9922 and #9865
This commit is contained in:
@@ -11,6 +11,8 @@ import { Uploads } from './collections/Uploads.js'
|
||||
import { Versions } from './collections/Versions.js'
|
||||
import { seed } from './seed.js'
|
||||
import {
|
||||
categoriesJoinRestrictedSlug,
|
||||
collectionRestrictedSlug,
|
||||
localizedCategoriesSlug,
|
||||
localizedPostsSlug,
|
||||
postsSlug,
|
||||
@@ -95,6 +97,25 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: categoriesJoinRestrictedSlug,
|
||||
admin: {
|
||||
useAsTitle: 'name',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
// join collection with access.read: () => false which should not populate
|
||||
name: 'collectionRestrictedJoin',
|
||||
type: 'join',
|
||||
collection: collectionRestrictedSlug,
|
||||
on: 'category',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: restrictedPostsSlug,
|
||||
admin: {
|
||||
@@ -120,6 +141,31 @@ export default buildConfigWithDefaults({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: collectionRestrictedSlug,
|
||||
admin: {
|
||||
useAsTitle: 'title',
|
||||
},
|
||||
access: {
|
||||
read: () => ({ canRead: { equals: true } }),
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'canRead',
|
||||
type: 'checkbox',
|
||||
defaultValue: false,
|
||||
},
|
||||
{
|
||||
name: 'category',
|
||||
type: 'relationship',
|
||||
relationTo: restrictedCategoriesSlug,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
localization: {
|
||||
locales: ['en', 'es'],
|
||||
|
||||
Reference in New Issue
Block a user