-
Hi, I'm using multiple upload-enables media collections (one for every user). When trying to reference the user's media collection from the richText field (upload element) Payload goes through ALL upload enables collections trying to access them. Of course my current user is not allowed to access the media collections of all other users. So my readAccess function denies access (as it does when trying to read any collection of another user). I don't know if this is a bug or if my multi-user setup is totally wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The full error thrown is:
In my opinion there should be no error, so we can have a multi-user setup with multiple media collections which are only accessible by the current user. Alternatively there could be a property like |
Beta Was this translation helpful? Give feedback.
-
Alright, in the meantin I've realized that I'm NOT supposed to separate user data on a collection level but on a doc level. For the sake of completeness I document here what I did wrong: I had a 'pages, 'media', etc collection for every user. // my access function
function allowSpecificUsers({ req }, allowedUsers = []) {
try {
//...
if (allowedUsers.includes(req?.user?.name)) {
return true
} else {
console.log(`[access] requesting collection "${req?.collection?.config?.slug}" user NOT allowed: "${req?.user?.name}"`)
return false
}
} catch (err) {
console.error(err)
}
}
// withing the collection (Donald Duck's collection)
access: {
read: ({ req }) => allowSpecificUsers({ req }, 'Donald Duck')
},
} This kind of setup worked fine until I encountered the error that I described above. |
Beta Was this translation helpful? Give feedback.
Alright, in the meantin I've realized that I'm NOT supposed to separate user data on a collection level but on a doc level.
This is because you can only return query constraints (by access functions) on a doc level.
For the sake of completeness I document here what I did wrong:
I had a 'pages, 'media', etc collection for every user.
Within the collections I hard coded the access restrictions.