-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add after_session_confirm hook after session confirmation #237
Add after_session_confirm hook after session confirmation #237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super great 👍
Thank you for such a thorough explanation. Few thoughts but happy to include this
Failing test is just |
Great work! ❤️🧡💛💚💙💜 |
@mikker when can we expect to see this released? |
Just pushed 1.8.0 with this change 😊 |
Am I correct in assuming the controller context is lot in the hook ? A use case would be for Ahoy to call Would it make sense to instead define the hook methods on the controller (kind of like Devise)? Then the Controller context is kept, and it is also easy to set a custom controller to use. |
Another note. It is not possible to have two different hooks. E.g one for AdminUsers and one for normal Users. Which having it as a controller method would handle. |
Good points Henrik! It could be useful to have the controller context at hand. Maybe something like if setting the hook setting to a Like class ApplicationController < ...
private
def pwless_after_session_confirm(session) # no need to pass request either
# ...
end
end
Passwordless.configure do |config|
config.after_session_confirm = :pwless_after_session_confirm
end That would make it a non-breaking change. |
fixes #213
This PR introduces a new
after_session_confirm
hook to the Passwordless gem. This feature allows users to perform custom actions after a session has been successfully confirmed, such as marking an email as verified or updating user attributes after their first successful login.Changes
after_session_confirm
configuration optionSessionsController
to call the hook after successful authenticationSessionsControllerTest
to cover the new functionalityMotivation
Users of the gem often need to perform specific actions after a successful login, such as updating user attributes or triggering other processes. The
after_session_confirm
hook provides a clean, configurable way to achieve this without modifying the gem's core code.Implementation Details
authenticate_and_sign_in
method ofSessionsController
, right after successful authentication but before redirecting the user.call
, it is silently ignored to maintain backwards compatibility.How to Use
Users can configure the hook in their Passwordless configuration:
Testing
New tests have been added to
SessionsControllerTest
to ensure the hook is called correctly in various scenarios:All existing tests pass with these new changes.
Reviewer Notes
SessionsController
to ensure it's in the most appropriate location.Checklist