Hey
I configured a policy to allow users to select their own User object based on 'id', but when I try to access it via admin the request arrives without the
id
property...
admin/collections/users/:id -> fails, id is undefined
api/users/:id -> works fine
the guard:
// src/collections/User.ts
const User = {
// ...
access: {
read: ({ req, id }) => req.user?.id === id
}
}
I fixed it returning a query constraint filtering the current user when user is not admin.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.