Skip to content

Commit 48d0fae

Browse files
authored
fix(next, ui): respect access of user for document locking (#9139)
1 parent 4f66514 commit 48d0fae

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

packages/next/src/views/Account/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ export const Account: React.FC<AdminViewProps> = async ({
9898
id: user.id,
9999
collectionConfig,
100100
isEditing: true,
101-
payload: req.payload,
102-
user,
101+
req,
103102
})
104103

105104
// Get all versions required for UI

packages/next/src/views/Document/getIsLocked.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
Payload,
2+
PayloadRequest,
33
SanitizedCollectionConfig,
44
SanitizedGlobalConfig,
55
TypedUser,
@@ -11,8 +11,7 @@ type Args = {
1111
globalConfig?: SanitizedGlobalConfig
1212
id?: number | string
1313
isEditing: boolean
14-
payload: Payload
15-
user: TypedUser
14+
req: PayloadRequest
1615
}
1716

1817
type Result = Promise<{
@@ -26,8 +25,7 @@ export const getIsLocked = async ({
2625
collectionConfig,
2726
globalConfig,
2827
isEditing,
29-
payload,
30-
user,
28+
req,
3129
}: Args): Result => {
3230
const entityConfig = collectionConfig || globalConfig
3331

@@ -61,17 +59,19 @@ export const getIsLocked = async ({
6159
]
6260
}
6361

64-
const { docs } = await payload.find({
62+
const { docs } = await req.payload.find({
6563
collection: 'payload-locked-documents',
6664
depth: 1,
65+
overrideAccess: false,
66+
req,
6767
where,
6868
})
6969

7070
if (docs.length > 0) {
7171
const newEditor = docs[0].user?.value
7272
const lastUpdateTime = new Date(docs[0].updatedAt).getTime()
7373

74-
if (newEditor?.id !== user.id) {
74+
if (newEditor?.id !== req.user.id) {
7575
return {
7676
currentEditor: newEditor,
7777
isLocked: true,

packages/next/src/views/Document/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ export const renderDocument = async ({
126126
collectionConfig,
127127
globalConfig,
128128
isEditing,
129-
payload: req.payload,
130-
user,
129+
req,
131130
}),
132131
])
133132

packages/ui/src/utilities/handleFormStateLocking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const handleFormStateLocking = async ({
6161
collection: 'payload-locked-documents',
6262
depth: 1,
6363
limit: 1,
64+
overrideAccess: false,
6465
pagination: false,
66+
req,
6567
where: lockedDocumentQuery,
6668
})
6769

0 commit comments

Comments
 (0)