Merge pull request #326 from Ducz0r/lm-sci-746-fix

Fix some recaptcha form submit errors for signup pages
This commit is contained in:
Luka Murn 2016-11-30 09:35:16 +01:00 committed by GitHub
commit d685ac939b
3 changed files with 18 additions and 1 deletions

View file

@ -8,6 +8,10 @@ module Users
before_filter :update_sanitized_params, only: :update
def edit
resource.full_name = ''
end
def update
# Instantialize a new organization with the provided name
@org = Organization.new
@ -158,8 +162,15 @@ module Users
def check_captcha
if Rails.configuration.x.enable_recaptcha
unless verify_recaptcha
# Construct new resource before rendering :new
self.resource = resource_class.new
resource.full_name = params[:user][:full_name]
resource.invitation_token = update_resource_params[:invitation_token]
# Also validate organization
@org = Organization.new(name: params[:organization][:name])
@org.valid?
respond_with_navigational(resource) { render :edit }
end
end

View file

@ -253,7 +253,13 @@ class Users::RegistrationsController < Devise::RegistrationsController
def check_captcha
if Rails.configuration.x.enable_recaptcha
unless verify_recaptcha
# Construct new resource before rendering :new
self.resource = resource_class.new sign_up_params
# Also validate organization
@org = Organization.new(name: params[:organization][:name])
@org.valid?
respond_with_navigational(resource) { render :new }
end
end

View file

@ -10,7 +10,7 @@
<div class="form-group">
<%= f.label :full_name %>
<%= f.text_field :full_name, value: '', autofocus: true, class: "form-control" %>
<%= f.text_field :full_name, value: resource.full_name, autofocus: true, class: "form-control" %>
</div>
<div class="form-group">