Class: Devise::Passwordless::SessionsController

Inherits:
SessionsController
  • Object
show all
Defined in:
app/controllers/devise/passwordless/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/devise/passwordless/sessions_controller.rb', line 2

def create
  if (self.resource = resource_class.find_for_authentication(email: create_params[:email]))
    send_magic_link(resource)
    if Devise.paranoid
      set_flash_message!(:notice, :magic_link_sent_paranoid)
    else
      set_flash_message!(:notice, :magic_link_sent)
    end
  else
    self.resource = resource_class.new(create_params)
    if Devise.paranoid
      set_flash_message!(:notice, :magic_link_sent_paranoid)
    else
      set_flash_message!(:alert, :not_found_in_database, now: true)
      render :new, status: devise_error_status
      return
    end
  end

  redirect_to(after_magic_link_sent_path_for(resource), status: devise_redirect_status)
end