API /Me Endpoint

default discord avatar
Nog
2 months ago
6

i have a collection called players with auth enabled. when logging in, i get a user object back with fields excluded like expected by access control settings set in the collection.


however, if i call the /Me endpoint, i get a full user object back. why does this happen or is this intended?



also i noticed that by the collection unused fields are send with as well, is there an option to change this ?

  • discord user avatar
    Jarrod
    Payload Team
    2 months ago

    1. That is interesting - @patrikkozak can you repro this?



    2. Can you clarify what you mean by "unused fields" my gut feeling is you are looking for something like graphql

  • default discord avatar
    Nog
    2 months ago

    with unused fields i mean for example a field that was renamed but exists in the db collection. i would have assummed all properties returned fromm the db would be filtered for those that exists in the defined collection.



    to reproduce have a field with a value in it, rename it ( now you have 2 , the old one and new one , old one only exists in db ) , fill that field.



    now do /me or login request. fields not mentioned in the collection definition for payload will be sent with.



    im filtering the responses now in hooks

  • discord user avatar
    Jarrod
    Payload Team
    2 months ago

    When you change a field config, we do not mutate your data. It’s up to you to migrate your data to the new field if you would like - or just keep both until you are ready to write a migration script to remove the old data. This is the expected behavior from payload, nature of nosql too

  • default discord avatar
    Nog
    2 months ago

    im not talking about the issue of migrating data, thats besides the point. what im talking about is that, in my mind the definition of the collection in payload should decide what fields the api returns, however it returns fields that are not defined in the config but exist only in the db.. fields which exist only there, need to be specifically defined to be excluded without doing so manually in hooks



    i thought the config to be inklusive for api returns, however its rather exklusive



    and me endpoint seems to return even less filtered results but as mentioned, can be handled as well in hooks

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.