beforeLogin deprecated?

default discord avatar
dsod
11 months 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
    Payload Team
    11 months 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
    dsod
    11 months 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

    @jmikrut

  • discord user avatar
    jmikrut
    Payload Team
    11 months ago

    @dsod we will review this today!

  • default discord avatar
    dsod
    11 months ago

    Thanks! 🙂

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

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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