-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3645 from jlledom/THREESCALE-9492-remove-suspicio…
…us-only THREESCALE-9492: Bot protection: Remove suspicious only mode
- Loading branch information
Showing
59 changed files
with
485 additions
and
933 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
module ThreeScale | ||
module BotProtection | ||
LEVELS = [['None', :none], ['reCAPTCHA', :captcha]].freeze | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module ThreeScale | ||
module BotProtection | ||
module Base | ||
def bot_protection_level | ||
site_account.settings.spam_protection_level | ||
end | ||
|
||
def bot_protection_enabled? | ||
Recaptcha.captcha_configured? && bot_protection_level != :none | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module ThreeScale | ||
module BotProtection | ||
module Controller | ||
include Base | ||
include Recaptcha::Adapters::ControllerMethods | ||
|
||
private | ||
|
||
def bot_check(options = { flash: true }) | ||
return true unless bot_protection_enabled? | ||
|
||
return verify_captcha(options) if bot_protection_level == :captcha | ||
|
||
System::ErrorReporting.report_error "Unknown spam_protection level: #{bot_protection_level}" | ||
end | ||
|
||
def verify_captcha(options) | ||
success = verify_recaptcha(action: controller_path, minimum_score: Rails.configuration.three_scale.recaptcha_min_bot_score) | ||
|
||
flash[:error] = flash[:recaptcha_error] if options[:flash] && flash.key?(:recaptcha_error) | ||
flash.delete(:recaptcha_error) | ||
|
||
success | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module ThreeScale | ||
module BotProtection | ||
module Form | ||
include Base | ||
include Recaptcha::Adapters::ViewMethods | ||
|
||
delegate :site_account, to: :template | ||
|
||
private | ||
|
||
def bot_protection_inputs | ||
return ''.html_safe unless bot_protection_enabled? | ||
|
||
recaptcha_v3(action: template.controller.controller_path) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.