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.

beforeLogin deprecated?

default discord avatar
dsod2 years ago
4

Tried to add some mutli-tenant login logic to the login operation through the

beforeLogin

hook, but I noticed that the hook isn't called in the login operation code, but

beforeOperation

are. Perhaps the

beforeLogin

is deprecated?



A

beforeLogin

hook would be useful in my case though, as I want to prevent the login under certain conditions. It is to late to do so in the

afterLogin

hook, and the

beforeOperation

hook doesn't give me the user document.

  • discord user avatar
    jmikrut
    2 years ago

    ahhh interesting



    i think we ended up removing beforeLogin as it was in the same position as the beforeOperation hook. What would you need to modify in this new hook? User? Token? Cookie?

  • default discord avatar
    dsod2 years ago

    I have a PR incoming 🙂 although, I realized I might simply be able to throw an error in the

    afterLogin

    hook to reject a login operation.



    Doing some more testing



    Simply throwing did the trick.


    I updated the docs and types in a PR though:


    https://github.com/payloadcms/payload/pull/1287

    Token is set before the

    afterLogin

    hook is called, so I'll create a PR where I bring back the

    beforeLogin

    again.. 🙂



    https://github.com/payloadcms/payload/pull/1289

    @364124941832159242
  • discord user avatar
    jmikrut
    2 years ago
    @397709884474261514

    we will review this today!

  • default discord avatar
    dsod2 years ago

    Thanks! 🙂

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.