Pass options
into server-side log-in lifecycle hooks
#13085
+336
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
Currently, any
options
provided by the log-in handler that services a log-in attempt are not passed to the server-sideAccounts.onLogin
and.onLoginFailure
lifecycle hooks as part of theattempt
. We use these lifecycle hooks for various integrations and application features, and it would be nice to be able to transport custom information between those two locations. Currently, we're doing something very unpleasant to bridge that gap.This change modifies
Accounts._attemptLogin
, following the pattern forerror
anduser
, attachingoptions
to theattempt
object being built there. This is really the only material change, but I've also done some more work.Related to this change is the following PR where a co-worker of mine made a similar change for the client-side
userCallback
ofAccounts.callLoginMethod
. My change brings parity on the server-side, making sureoptions
are passed everywhere they might be useful.As a gesture of good will 😇, I have also written a small suite of tests that covers:
Accounts.validateLoginAttempt
hookAccounts.onLogin
hookAccounts.onLoginFailure
hook(These tests essentially cover my co-worker's PR changes from before.)
validateResult
callbackuserCallback
callbackPotentially Contentious Things
MockFunction
class and added it totest-helpers
. I considered it to be an expedient in writing these tests, but if it's too new or out of line with what you want in your test suite, please let me know.accounts_tests_setup.js
, but please let me know if I did that wrong.Accounts.registerLoginHandler
function with a test-only handler. I wanted to write tests that were focused in scope, and so that's how I went about it, rather than relying on existing handlers that might've been added in other packages.