Login as multiple auth-enabled collections

default discord avatar
2 years ago
1 1

Is it possible to login as multiple auth-enabled collections simultaneously?

Let's say I have Users collection and Admins collection, and I want to be be logged in as both User (in the frontend part) and Admin (in the admin panel) at the same time. Is it doable?

Right now, both Auth collections overwrite each other's payload-token cookie. Would it be enough to simply use different cookie names? Is it configurable?

  • discord user avatar
    Payload Team
    2 years ago

    Hey @sixers!

    Unfortunately there are many complexities below the surface of doing something like this.

    For example, if you were logged in as 2 different users, how would Payload know which user you were intending to be using for any given request? Payload operations access the currently authenticated user from req.user - and while it would be easy enough to change this pattern to use req.users or similar instead, we would still need to know which user to rely on.

    Making auth cookie names dynamic would certainly be one piece of the puzzle, but there are many more complex issues and use cases that would need to be thought through fully here.

    We can keep it on the radar for sure though. What do you think?

    1 reply
  • default discord avatar
    2 years ago

    Thanks! Ok, that makes sense. In that case, I'll combine the two collections. I wanted to keep them separate, because they have completely different fields, but it's not a big deal.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.