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
cyanph03nixlast year
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?

  • default discord avatar
    hristo6004last year

    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.

  • default discord avatar
    cyanph03nixlast year

    You are a legend, thankyou!

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.