2020-11-16 07:09:05 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module RecaptchaHelper
|
2021-11-02 11:12:22 -04:00
|
|
|
def recaptcha_enabled?
|
2022-10-03 08:08:27 -04:00
|
|
|
return false if gitlab_qa?
|
|
|
|
|
2020-11-16 07:09:05 -05:00
|
|
|
!!Gitlab::Recaptcha.enabled?
|
|
|
|
end
|
2021-11-02 11:12:22 -04:00
|
|
|
alias_method :show_recaptcha_sign_up?, :recaptcha_enabled?
|
2022-10-03 08:08:27 -04:00
|
|
|
|
|
|
|
def recaptcha_enabled_on_login?
|
|
|
|
return false if gitlab_qa?
|
|
|
|
|
|
|
|
Gitlab::Recaptcha.enabled_on_login?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def gitlab_qa?
|
|
|
|
return false unless Gitlab.com?
|
|
|
|
return false unless request.user_agent.present?
|
|
|
|
return false unless Gitlab::Environment.qa_user_agent.present?
|
|
|
|
|
|
|
|
ActiveSupport::SecurityUtils.secure_compare(request.user_agent, Gitlab::Environment.qa_user_agent)
|
|
|
|
end
|
2020-11-16 07:09:05 -05:00
|
|
|
end
|
2021-09-13 17:08:53 -04:00
|
|
|
|
|
|
|
RecaptchaHelper.prepend_mod
|