diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb new file mode 100644 index 000000000..2751bc988 --- /dev/null +++ b/app/controllers/organizations/registrations_controller.rb @@ -0,0 +1,29 @@ +class Organizations::RegistrationsController < Devise::RegistrationsController + include RecaptchaHelper + + def new + super do |user| + user.build_organization + end + end + + def create + if verify_captcha?(resource) + super do |user| + # Removes unuseful "organization is invalid" error message + user.errors.messages.delete(:organization) + end + else + build_resource(sign_up_params) + flash.now[:alert] = t('recaptcha.errors.verification_failed') + respond_with resource + end + end + + private + + def sign_up_params + params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, organization_attributes: [:name]) + end + +end diff --git a/app/views/organizations/registrations/new.html.erb b/app/views/organizations/registrations/new.html.erb new file mode 100644 index 000000000..f8ca107be --- /dev/null +++ b/app/views/organizations/registrations/new.html.erb @@ -0,0 +1,64 @@ +