diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index 907477c2f..444e02a8f 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -2,6 +2,8 @@ module Users class InvitationsController < Devise::InvitationsController include UsersGenerator + prepend_before_action :check_captcha, only: [:update] + before_action :check_invite_users_permission, only: :invite_users def update @@ -146,6 +148,16 @@ module Users private + def check_captcha + if Rails.configuration.x.enable_recaptcha + unless verify_recaptcha + self.resource = resource_class.new + resource.invitation_token = update_resource_params[:invitation_token] + respond_with_navigational(resource) { render :edit } + end + end + end + def generate_notification(user, target_user, role, org) title = I18n.t('notifications.assign_user_to_organization', assigned_user: target_user.name, diff --git a/app/views/users/invitations/edit.html.erb b/app/views/users/invitations/edit.html.erb index f50d1bbd5..94fe6255e 100644 --- a/app/views/users/invitations/edit.html.erb +++ b/app/views/users/invitations/edit.html.erb @@ -31,6 +31,17 @@ <%= t 'users.registrations.new.team_name_help' %> + <% if Rails.configuration.x.enable_recaptcha %> +