Skip to content

Commit

Permalink
tidy up function definition order
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Oct 5, 2022
1 parent 07dd254 commit 2aacbc9
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions packages/core/src/lib/core/mutations/access-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,55 +216,55 @@ async function enforceFieldLevelAccessControl({
}
}

export async function getAccessControlledItemForUpdate(
export async function applyAccessControlForCreate(
list: InitialisedList,
context: KeystoneContext,
uniqueWhere: UniquePrismaFilter,
accessFilters: boolean | InputFilter,
inputData: Record<string, any>
inputData: Record<string, unknown>
) {
// apply filter access control - throws accessDeniedError on item not found
const item = await getFilteredItem(list, context, uniqueWhere!, accessFilters, 'update');

await enforceListLevelAccessControl({
context,
operation: 'update',
operation: 'create',
list,
inputData,
item,
item: undefined,
});

await enforceFieldLevelAccessControl({
context,
operation: 'update',
operation: 'create',
list,
inputData,
item,
item: undefined,
});

return item;
}

export async function applyAccessControlForCreate(
export async function getAccessControlledItemForUpdate(
list: InitialisedList,
context: KeystoneContext,
inputData: Record<string, unknown>
uniqueWhere: UniquePrismaFilter,
accessFilters: boolean | InputFilter,
inputData: Record<string, any>
) {
// apply filter access control - throws accessDeniedError on item not found
const item = await getFilteredItem(list, context, uniqueWhere!, accessFilters, 'update');

await enforceListLevelAccessControl({
context,
operation: 'create',
operation: 'update',
list,
inputData,
item: undefined,
item,
});

await enforceFieldLevelAccessControl({
context,
operation: 'create',
operation: 'update',
list,
inputData,
item: undefined,
item,
});

return item;
}

export async function getAccessControlledItemForDelete(
Expand Down

0 comments on commit 2aacbc9

Please sign in to comment.