fix(next, ui): respect access of user for document locking (#9139)

This commit is contained in:
Patrik
2024-11-12 10:49:58 -05:00
committed by GitHub
parent 4f6651433c
commit 48d0faecae
4 changed files with 11 additions and 11 deletions

View File

@@ -98,8 +98,7 @@ export const Account: React.FC<AdminViewProps> = async ({
id: user.id, id: user.id,
collectionConfig, collectionConfig,
isEditing: true, isEditing: true,
payload: req.payload, req,
user,
}) })
// Get all versions required for UI // Get all versions required for UI

View File

@@ -1,5 +1,5 @@
import type { import type {
Payload, PayloadRequest,
SanitizedCollectionConfig, SanitizedCollectionConfig,
SanitizedGlobalConfig, SanitizedGlobalConfig,
TypedUser, TypedUser,
@@ -11,8 +11,7 @@ type Args = {
globalConfig?: SanitizedGlobalConfig globalConfig?: SanitizedGlobalConfig
id?: number | string id?: number | string
isEditing: boolean isEditing: boolean
payload: Payload req: PayloadRequest
user: TypedUser
} }
type Result = Promise<{ type Result = Promise<{
@@ -26,8 +25,7 @@ export const getIsLocked = async ({
collectionConfig, collectionConfig,
globalConfig, globalConfig,
isEditing, isEditing,
payload, req,
user,
}: Args): Result => { }: Args): Result => {
const entityConfig = collectionConfig || globalConfig const entityConfig = collectionConfig || globalConfig
@@ -61,9 +59,11 @@ export const getIsLocked = async ({
] ]
} }
const { docs } = await payload.find({ const { docs } = await req.payload.find({
collection: 'payload-locked-documents', collection: 'payload-locked-documents',
depth: 1, depth: 1,
overrideAccess: false,
req,
where, where,
}) })
@@ -71,7 +71,7 @@ export const getIsLocked = async ({
const newEditor = docs[0].user?.value const newEditor = docs[0].user?.value
const lastUpdateTime = new Date(docs[0].updatedAt).getTime() const lastUpdateTime = new Date(docs[0].updatedAt).getTime()
if (newEditor?.id !== user.id) { if (newEditor?.id !== req.user.id) {
return { return {
currentEditor: newEditor, currentEditor: newEditor,
isLocked: true, isLocked: true,

View File

@@ -126,8 +126,7 @@ export const renderDocument = async ({
collectionConfig, collectionConfig,
globalConfig, globalConfig,
isEditing, isEditing,
payload: req.payload, req,
user,
}), }),
]) ])

View File

@@ -61,7 +61,9 @@ export const handleFormStateLocking = async ({
collection: 'payload-locked-documents', collection: 'payload-locked-documents',
depth: 1, depth: 1,
limit: 1, limit: 1,
overrideAccess: false,
pagination: false, pagination: false,
req,
where: lockedDocumentQuery, where: lockedDocumentQuery,
}) })