Skip to content

Commit

Permalink
Extract send_magic_link out to a method
Browse files Browse the repository at this point in the history
I've extracted the code to send the magic link out to it's own method, which allows it to be overridden in other apps using this gem if they want to perform additional actions when the email is sent successfully.

This can already be done using the `send_magic_link` method on the "user" model, but sometimes the logic you want to add doesn't make sense in the model layer.
  • Loading branch information
iainbeeston authored and abevoelker committed May 1, 2024
1 parent 8db79dd commit 8c62bb8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/devise/passwordless/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Devise::Passwordless::SessionsController < Devise::SessionsController
def create
if (self.resource = resource_class.find_for_authentication(email: create_params[:email]))
resource.send_magic_link(remember_me: create_params[:remember_me])
send_magic_link(resource)
if Devise.paranoid
set_flash_message!(:notice, :magic_link_sent_paranoid)
else
Expand All @@ -23,6 +23,10 @@ def create

protected

def send_magic_link(resource)
resource.send_magic_link(remember_me: create_params[:remember_me])
end

def translation_scope
if action_name == "create"
"devise.passwordless"
Expand Down

0 comments on commit 8c62bb8

Please sign in to comment.