fix: #2592, allows usage of hidden fields within access query constraints (#2599)

Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
James Mikrut
2023-05-01 17:15:14 -04:00
committed by GitHub
parent 870838e756
commit a0bb13a412
18 changed files with 262 additions and 325 deletions

View File

@@ -15,6 +15,8 @@ export const relyOnRequestHeadersSlug = 'rely-on-request-headers';
export const docLevelAccessSlug = 'doc-level-access';
export const hiddenFieldsSlug = 'hidden-fields';
export const hiddenAccessSlug = 'hidden-access';
const openAccess = {
create: () => true,
read: () => true,
@@ -187,9 +189,31 @@ export default buildConfig({
name: 'name',
type: 'text',
},
{
name: 'hidden',
type: 'checkbox',
hidden: true,
},
],
access: {
readVersions: () => false,
read: ({ req: { user } }) => {
if (user) return true;
return {
hidden: {
not_equals: true,
},
};
},
readVersions: ({ req: { user } }) => {
if (user) return true;
return {
'version.hidden': {
not_equals: true,
},
};
},
},
},
{
@@ -320,6 +344,37 @@ export default buildConfig({
},
],
},
{
name: 'hidden',
type: 'checkbox',
hidden: true,
},
],
},
{
slug: hiddenAccessSlug,
access: {
read: ({ req: { user } }) => {
if (user) return true;
return {
hidden: {
not_equals: true,
},
};
},
},
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'hidden',
type: 'checkbox',
hidden: true,
},
],
},
],