Commit 26516d96 authored by Vincent Fazio's avatar Vincent Fazio

Create new setting for user deactivation emails

With the introduction of:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64964

Email notifications are sent to users when their account is deactivated.
This was an automatic change to behavior without an option to disable.

Administrators often deactivate users to control instance license usage.
Sending an email to users can defeat the purpose of deactivation since
an alerted user can reactivate their account and consume a license.

A new setting enables administrators to control whether or not email
notifications will be sent to users upon account deactivation.

Changelog: added
Signed-off-by: default avatarVincent Fazio <vfazio@xes-inc.com>
parent c79b6851
......@@ -383,7 +383,8 @@ module ApplicationSettingsHelper
:container_registry_expiration_policies_worker_capacity,
:container_registry_cleanup_tags_service_max_list_size,
:keep_latest_artifact,
:whats_new_variant
:whats_new_variant,
:user_deactivation_emails_enabled
].tap do |settings|
settings << :deactivate_dormant_users unless Gitlab.com?
end
......
......@@ -208,7 +208,8 @@ module ApplicationSettingImplementation
kroki_url: nil,
kroki_formats: { blockdiag: false, bpmn: false, excalidraw: false },
rate_limiting_response_text: nil,
whats_new_variant: 0
whats_new_variant: 0,
user_deactivation_emails_enabled: true
}
end
......
......@@ -385,6 +385,8 @@ class User < ApplicationRecord
end
after_transition any => :deactivated do |user|
next unless Gitlab::CurrentSettings.user_deactivation_emails_enabled
NotificationService.new.user_deactivated(user.name, user.notification_email)
end
# rubocop: enable CodeReuse/ServiceClass
......
......@@ -33,4 +33,12 @@
.form-text.text-muted
= _('Send emails to help guide new users through the onboarding process.')
.form-group
.form-check
= f.check_box :user_deactivation_emails_enabled, class: 'form-check-input'
= f.label :user_deactivation_emails_enabled, class: 'form-check-label' do
= _('Enable user deactivation emails')
.form-text.text-muted
= _('Send emails to users upon account deactivation.')
= f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' }
# frozen_string_literal: true
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddUserDeactivationEmailOptionToApplicationSettings < ActiveRecord::Migration[6.1]
def change
add_column :application_settings, :user_deactivation_emails_enabled, :boolean, default: true, null: false
end
end
43d152f4235a07111a401be7b52a527571be04861c71381c311d6a48c8574dc9
\ No newline at end of file
......@@ -10390,6 +10390,7 @@ CREATE TABLE application_settings (
throttle_authenticated_git_lfs_requests_per_period integer DEFAULT 1000 NOT NULL,
throttle_authenticated_git_lfs_period_in_seconds integer DEFAULT 60 NOT NULL,
throttle_authenticated_git_lfs_enabled boolean DEFAULT false NOT NULL,
user_deactivation_emails_enabled boolean DEFAULT true NOT NULL,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
......@@ -176,6 +176,7 @@ module API
optional :require_admin_approval_after_user_signup, type: Boolean, desc: 'Require explicit admin approval for new signups'
optional :whats_new_variant, type: String, values: ApplicationSetting.whats_new_variants.keys, desc: "What's new variant, possible values: `all_tiers`, `current_tier`, and `disabled`."
optional :floc_enabled, type: Grape::API::Boolean, desc: 'Enable FloC (Federated Learning of Cohorts)'
optional :user_deactivation_emails_enabled, type: Boolean, desc: 'Send emails to users upon account deactivation'
ApplicationSetting::SUPPORTED_KEY_TYPES.each do |type|
optional :"#{type}_key_restriction",
......
......@@ -12535,6 +12535,9 @@ msgstr ""
msgid "Enable unauthenticated request rate limit"
msgstr ""
msgid "Enable user deactivation emails"
msgstr ""
msgid "Enable version check"
msgstr ""
......@@ -30326,6 +30329,9 @@ msgstr ""
msgid "Send emails to help guide new users through the onboarding process."
msgstr ""
msgid "Send emails to users upon account deactivation."
msgstr ""
msgid "Send message"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment