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.
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?
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:
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
@dsod we will review this today!
Thanks! 🙂
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.