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.

managing user/customer logins with payload

default discord avatar
thesodapoppandalast year
3

Let's say you have an online store or app that uses payload what would be the easiest way to manage user/customer logins is there a built-in system or a commonly used workaround?



the expectation is that customers/users would not be able to access the CMS but would be able to log in via a separate login page, interacting with payload operations they have access to?



PS: thanks in advance just learning payload so far it's been amazing! super excited to use it in my current and future projects!

  • default discord avatar
    dan.was.herelast year

    you can create users with different access rights. you don't have to give them access to the admin at all or a limited admin panel.



    if you wanna check out the ecommerce template for example, there's a login form in the frontend, that uses the auth of payload, but doesn't give them access to the admin panel

  • default discord avatar
    thesodapoppandalast year

    Hey amazing! Thank you!



    Edit: payload ecommerce template has an example of exactly what I was looking for.


    https://github.com/payloadcms/payload/tree/main/templates/ecommerce

    solution:

      access: {
        read: adminsAndUser,
        create: anyone,
        update: adminsAndUser,
        delete: admins,
        admin: ({ req: { user } }) => checkRole(['admin'], user),
      },

    Example for implementing auth context on nextjs/react using Content (from ecommerce )


    https://github.com/payloadcms/payload/blob/main/templates/ecommerce/src/app/_providers/Auth/index.tsx
  • default discord avatar
    waterlord9310 months ago

    thank you for linking resources, came here from discord search and this is exactly what i needed :)

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.