Authentication user "hold" for additional auth check #37028
Unanswered
DarkGhostHunter
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One of the most problematic authentication procedures in Laravel is to "hold" the user being authenticated for another check in the next request.
For example, an User may have Two-Factor Authentication (2FA) enabled. The only way to implement this system is by, in order of simplicity:
Validated
.I think the authentication system could have a "on-hold" user on the session once the credentials are validated. It would work much like
attempt()
, but it would allow a set of callbacks to run before login the user in.The
attemptWith()
method retrieves and validates the user, but doesn't logs him unless the next callback returns true, allowing the developer to intercede before the login, and without having to create a new Guard.As you can see, the
attemptWith()
is pretty much the same asattempt()
in theSessionGuard
, but has additional checks to allow further callbacks to execute over the User.If this is considered a good idea, it may be good to know which implementation could be the best:
attempt()
signature of the Contract, or add it asattemptWith()
.SessionGuard
only.Beta Was this translation helpful? Give feedback.
All reactions