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.

Restrict access to admin panel unless role is admin

default discord avatar
cyanph03nix10 months ago
2

Im trying to create a client portal and dont want the clients being able to login to the admin panel but cant find anything anywhere on how to do this?



You are a legend, thankyou!

  • default discord avatar
    hristo600411 months ago

    In your Users collection (or the one you're using for auth, under

    access

    you can add additional property

    admin

    :



      access: {
        create: // ...,
        read: // ... ,
        update: // ...,
        delete: // ...,
        admin: ({ req: { user } }) => user?.role === 'admin',
      },


    This way, only users with the role

    admin

    will be able to access the admin panel.

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.