I am getting this error when I am trying to hit api/users endpoint 403 error
[12:12:46] ERROR (payload): Forbidden: You are not allowed to perform this action.
at executeAccess (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\auth\executeAccess.js:9:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async find (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\collections\operations\find.js:38:24)
at async findHandler (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\collections\requestHandlers\find.js:19:24)
This is the error I am getting
Good morning
@1098978780116168714- on your users Collection, do you have access control set?
access: {
read: () => true,
create: () => true,
update: () => true
},
It looks something like this
And typically is the reason for permission issues like the above error
Hi
@1049775120559898725, The access control is not set in any of my collection I will set that but I am unable to access Users collection in the buildConfig. The Users collection was prebuilt at the time I initialized the buildConfig the following way
export default buildConfig({
// By default, Payload will boot up normally
// and you will be provided with a base
User
collection.
// But, here is where you define how you'd like Payload to work!
});
Can you please confirm me how I can get the Users collection so that I can add access to it
The Users collection is in your collections folder
Are you able to locate the Users file?
I have installed payload in a existing express app and In my src/collections folder I do not have Users file. I also tried to find Users file in the require('payload/dist/collections') also but I was unable to find
What is in your collections folder?
Got resolved Thanks
this solved my problem
Glad that worked! Remember, those are good values for testing, but be cautious of having access settings that are too lax!
yep it's only read: () => true in my case 😉
hello. I created a new collection type with just one field (media upload that refers to media collection) in a blank project. I was able to add once record. yet, in the next records I kept seeing an error:
const Testimonials: CollectionConfig = {
slug: 'testimonials',
fields: [
{ name: 'image', type: 'upload', relationTo: 'media', required: true }
],
access: {
read: () => true
}
};
export default Testimonials;
and this is my config:
export default buildConfig({
admin: {
user: Users.slug,
},
collections: [
Users,
Treatments,
Media,
Testimonials
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [
payloadCloud()
]
});
it is uploading the media but not saving the collection
[13:16:45] ERROR (payload): ValidationError: The following field is invalid: email
at create (/....../node_modules/payload/src/collections/operations/create.ts:213:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at createHandler (/..../node_modules/payload/src/collections/requestHandlers/create.ts:19:17)
hey I understood the issue. it only works when auth: true in the CollectionConfig. but to be honest I don't like the fact that there is a need to fill email/password each time creating a new entry
I had the same issue, this fixed my problem:
Star
Discord
online
Get dedicated engineering support directly from the Payload team.