Is there a global login by rest api?

default discord avatar
Iván Dominguez (Domi)
6 months ago
4

Hello community. I want my application that uses payload to have a global login and not by collection. This login should return me a token which would give me access to query all collections.

  • discord user avatar
    jacobsfletch
    Payload Team
    6 months ago

    Authentication is always per-collection but it sounds like you might want to implement basic access control. If you give your auth-enabled collection a

    roles

    field then controlled access based on its value, you could provide some users with “super-admin” capabilities while restricting the others

  • default discord avatar
    Iván Dominguez (Domi)
    6 months ago

    hi @jacobsfletch !


    Thanks for your quick response.



    That sounds really good. Do you know where I can configure the collections so that they restrict their access based on a user role?

  • discord user avatar
    jacobsfletch
    Payload Team
    6 months ago

    Use the

    access

    property on your collection config, here’s an example

    https://github.com/payloadcms/payload/blob/master/examples/auth/cms/src/collections/Users.ts

    and then here’s the doc for reference

    https://payloadcms.com/docs/access-control/overview#access-control
  • default discord avatar
    Iván Dominguez (Domi)
    6 months ago

    Thank you very much for the info!!

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.