passwordless icon indicating copy to clipboard operation
passwordless copied to clipboard

Add `after_session_confirm` hook after session confirmation

Open onedanshow opened this issue 1 year ago • 2 comments

Just a suggestion to add a after_session_confirm similar to after_session_save. This would let folks mark accounts as "verified" or "has_verified_email" after session confirmation.

onedanshow avatar Apr 01 '24 16:04 onedanshow

Good idea!

mikker avatar Apr 03 '24 07:04 mikker

This would be a great feature. I'm marking the "email_verified" field if current_user is present. I have added this check in ApplicationController, which is not ideal as it checks on every single request.

I looked around the code to see if I can contribute in any way but not sure what would be the best way to add this. May be somewhere in authenticate_and_sign_in?

onerinas avatar May 22 '24 20:05 onerinas

I submitted a PR #237 that solves this issue and adds a configuration key to setup the hook like:

Passwordless.configure do |config|
  config.after_session_confirm = ->(session) {
    user = session.authenticatable
    user.update(email_verified: true)
  }
end

@mikker @onerinas @onedanshow @Ardnived

wilburhimself avatar Oct 07 '24 07:10 wilburhimself

Responded in PR. Thank you for contributing @wilburhimself !

mikker avatar Oct 07 '24 10:10 mikker