thomas4019 / expressa

API creation middleware with an admin interface
MIT License
439 stars 27 forks source link

register and login listeners #181

Open kane-mason opened 2 years ago

kane-mason commented 2 years ago

it would be great to be able to define listners for a register and login request

one such use case is to mange complex login scenarios such as social login, multifactor authentication etc

thomas4019 commented 2 years ago

You can listen to registering by listening to post on the users collection. Something custom for Login does seem like a good idea.

kane-mason commented 2 years ago

@thomas4019 any suggestions for the login listener? I can see cases for both before the doLogin and after.. I can also see a case for allowing a replace of the entire login handler for those who have MFA login, or want to login with something other than email like a cell number

thomas4019 commented 2 years ago

I'd recommend only adding as much as you feel is needed for your use case. Also, supporting alternative login types is currently probably easier by modifying the expressa codebase directly rather than adding/implementing some new handler system.

I think a beforeLogin and afterLogin seems sufficient to me.