Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

API /Me Endpoint

default discord avatar
shiru_nog2 years ago
4

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_not_jared
    2 years ago

    1. That is interesting -

    @1032341301619871785

    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
    shiru_nog2 years 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_not_jared
    2 years 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
    shiru_nog2 years 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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.