ausent id on selecting a particular user via admin

default discord avatar
.hawk_e
4 months ago
1

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.

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.