wahanegi/vibereport

View on GitHub
app/controllers/devise/passwordless/magic_links_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class Devise::Passwordless::MagicLinksController < DeviseController
  prepend_before_action :require_no_authentication, only: :show
  prepend_before_action :allow_params_authentication!, only: :show
  prepend_before_action(only: [:show]) { request.env['devise.skip_timeout'] = true }

  def show
    self.resource = warden.authenticate!(auth_options)
    sign_in(resource_name, resource)
    yield resource if block_given?
    redirect_to after_sign_in_path_for(resource)
  end

  protected

  def auth_options
    mapping = Devise.mappings[resource_name]
    { scope: resource_name, recall: "#{mapping.controllers[:sessions]}#new" }
  end

  def translation_scope
    'devise.sessions'
  end

  private

  def create_params
    resource_params.permit(:email, :remember_me)
  end
end