Sha256: 7c96b4c535793a805667021172f2038beccba7ed5dfcd87f7696870b436f98ea

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

class Devise::ParanoidVerificationCodeController < DeviseController
  skip_before_action :handle_paranoid_verification
  prepend_before_action :authenticate_scope!, only: [:show, :update]

  def show
    if !resource.nil? && resource.need_paranoid_verification?
      respond_with(resource)
    else
      redirect_to :root
    end
  end

  def update
    if resource.verify_code(resource_params[:paranoid_verification_code])
      warden.session(scope)['paranoid_verify'] = false
      set_flash_message :notice, :updated
      bypass_sign_in resource, scope: scope
      redirect_to stored_location_for(scope) || :root
    else
      respond_with(resource, action: :show)
    end
  end

  private

  def resource_params
    if params.respond_to?(:permit)
      params.require(resource_name).permit(:paranoid_verification_code)
    else
      params[scope].slice(:paranoid_verification_code)
    end
  end

  def scope
    resource_name.to_sym
  end

  def authenticate_scope!
    send(:"authenticate_#{resource_name}!")
    self.resource = send("current_#{resource_name}")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
devise-security-0.16.0 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.15.0 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.14.3 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.14.2 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.14.1 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.14.0 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.14.0.rc1 app/controllers/devise/paranoid_verification_code_controller.rb
devise-security-0.13.0 app/controllers/devise/paranoid_verification_code_controller.rb