From 84acf3775e29aee437c3e56c09b25e8632f594e7 Mon Sep 17 00:00:00 2001 From: Joonas Date: Tue, 10 Sep 2024 12:40:44 +0300 Subject: [PATCH] Add private user admin fixes --- ...icipatory_space_private_user_extensions.rb | 27 +++++++++++++++++++ lib/decidim/privacy/engine.rb | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 app/commands/concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions.rb diff --git a/app/commands/concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions.rb b/app/commands/concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions.rb new file mode 100644 index 0000000..85d91f7 --- /dev/null +++ b/app/commands/concerns/decidim/privacy/admin/create_participatory_space_private_user_extensions.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Decidim + module Privacy + module Admin + module CreateParticipatorySpacePrivateUserExtensions + extend ActiveSupport::Concern + + included do + private + + def existing_user + return @existing_user if defined?(@existing_user) + + @existing_user = Decidim::User.entire_collection.find_by( + email: form.email.downcase, + organization: private_user_to.organization + ) + + InviteUserAgain.call(@existing_user, invitation_instructions) if @existing_user&.invitation_pending? + @existing_user + end + end + end + end + end +end diff --git a/lib/decidim/privacy/engine.rb b/lib/decidim/privacy/engine.rb index 5bc162e..dbd1529 100644 --- a/lib/decidim/privacy/engine.rb +++ b/lib/decidim/privacy/engine.rb @@ -113,6 +113,9 @@ class Engine < ::Rails::Engine # The following changes are related to "Ask old password for changing email/password(PR #11737)" # These changes should be removed once it has been backported to v.27 Decidim::UpdateAccount.include(Decidim::Privacy::UpdateAccountExtensions) + Decidim::Admin::CreateParticipatorySpacePrivateUser.include( + Decidim::Privacy::Admin::CreateParticipatorySpacePrivateUserExtensions + ) # controllers Decidim::ApplicationController.include(