Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8212] Rescue from missing contact form params #8214

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/controllers/help_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class HelpController < ApplicationController
before_action :catch_spam, only: [:contact]
before_action :set_recaptcha_required, only: [:contact]

ContactSpamError = Class.new(StandardError)

rescue_from ContactSpamError, ActionController::ParameterMissing do
redirect_to frontpage_url
end

def index
redirect_to help_about_path
end
Expand Down Expand Up @@ -89,7 +95,7 @@ def catch_spam
return unless request.post? && params[:contact]
return if params[:contact].fetch(:comment, '').blank?

redirect_to frontpage_url
raise ContactSpamError
end

def set_recaptcha_required
Expand Down
Loading