Sha256: 970019ec95283ed8d86bd98b1e1a0b75b847426f6663959a6b9bfc09287fcc25

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

class Kiqr::SessionsController < Devise::SessionsController
  include Kiqr::Controllers::TwoFactorAuthentication

  before_action :authenticate_with_two_factor, if: -> { action_name == "create" && two_factor_enabled? }

  private

  def two_factor_enabled?
    find_user&.two_factor_enabled?
  end

  def find_user
    if sign_in_params[:email]
      User.find_by(email: sign_in_params[:email])
    elsif session[:otp_user_id]
      User.find(session[:otp_user_id])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kiqr-0.1.0.alpha1 app/controllers/kiqr/sessions_controller.rb