Module: DeviseSecurity::Controllers::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise-security/controllers/helpers.rb

Defined Under Namespace

Modules: ClassMethods, RecoverPasswordCaptcha

Instance Method Summary collapse

Instance Method Details

#valid_captcha_if_defined?(captcha) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
34
# File 'lib/devise-security/controllers/helpers.rb', line 31

def valid_captcha_if_defined?(captcha)
  defined?(verify_recaptcha) && verify_recaptcha ||
    defined?(valid_captcha?) && valid_captcha?(captcha)
end

#valid_captcha_or_security_question?(resource, params) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
29
# File 'lib/devise-security/controllers/helpers.rb', line 26

def valid_captcha_or_security_question?(resource, params)
  valid_captcha_if_defined?(params[:captcha]) ||
    valid_security_question_answer?(resource, params[:security_question_answer])
end

#valid_security_question_answer?(resource, answer) ⇒ Boolean

Returns:

  • (Boolean)

36
37
38
39
# File 'lib/devise-security/controllers/helpers.rb', line 36

def valid_security_question_answer?(resource, answer)
  resource.security_question_answer.present? &&
    resource.security_question_answer == answer
end