diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index 8132fd277..c65b2f131 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -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 diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 0f0094195..11d35d4ea 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -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 diff --git a/app/views/users/invitations/edit.html.erb b/app/views/users/invitations/edit.html.erb index eb71e836c..cc6d101ff 100644 --- a/app/views/users/invitations/edit.html.erb +++ b/app/views/users/invitations/edit.html.erb @@ -10,7 +10,7 @@