Add optional on_login_success callback #90
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.
This adds a new
on_login_success
configuration option. If this option is set to aProc
and the login was successful, theProc
will be called in the context of theRpiAuth::AuthController#callback
action, i.e.current_user
will be available. This is intended to allow apps to record successful logins.I'm not convinced that using
instance_exec
is the most sensible approach, but I decided it was better to be consistent with the way thesuccess_redirect
option is implemented.If the
Proc
raises an exception, this will be rescued and the exception will be logged as a warning in the Rails log. This is so that the login will still complete successfully, even if there was a problem recording it.The immediate motivation for adding this is so we can record successful student logins in
experience-cs
in order to be able to calculate the "active users" metric described in this issue. Unfortunately while this information is available in theprofile
app database for regular users; it's not available for student users.