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

Enable recaptcha for contact_us form: fixes #501 #1385

Merged
merged 1 commit into from
Apr 16, 2018
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
31 changes: 31 additions & 0 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class ContactUs::ContactsController < ApplicationController

def create
@contact = ContactUs::Contact.new(params[:contact_us_contact])

if verify_recaptcha(model: @contact) && @contact.save
redirect_to(ContactUs.success_redirect || '/', :notice => _('Contact email was successfully sent.'))
else
flash[:alert] = _('Captcha verification failed, please retry.')
redirect_to request.referrer
#render_new_page
end
end

def new
@contact = ContactUs::Contact.new
render_new_page
end

protected

def render_new_page
case ContactUs.form_gem
when 'formtastic' then render 'new_formtastic'
when 'simple_form' then render 'new_simple_form'
else
render 'new'
end
end

end