Sha256: dc561bc1d2b8cc37f6aeefe9d681f292ae3485e7f8e53024986d0d1224d1e107

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

module DeviseSecurity::Patches
  module ControllerSecurityQuestion
    extend ActiveSupport::Concern

    included do
      prepend_before_action :check_security_question, only: [:create]
    end

    private
    def check_security_question
      # only find via email, not login
      resource = resource_class.find_or_initialize_with_error_by(:email, params[resource_name][:email], :not_found)
      return if valid_security_question_answer?(resource, params[:security_question_answer])

      flash[:alert] = t('devise.invalid_security_question') if is_navigational_format?
      respond_with({}, location: url_for(action: :new))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise-security-0.12.0 lib/devise-security/patches/controller_security_question.rb
devise-security-0.11.1 lib/devise-security/patches/controller_security_question.rb