Commit 461a2845 authored by Serena Fang's avatar Serena Fang Committed by Bob Van Landuyt

Email user when account deactivated

parent 7bd32bfe
......@@ -26,6 +26,14 @@ module Emails
subject: subject(_("GitLab account request rejected")))
end
def user_deactivated_email(name, email)
@name = name
profile_email_with_layout(
to: email,
subject: subject(_('Your account has been deactivated')))
end
# rubocop: disable CodeReuse/ActiveRecord
def new_ssh_key_email(key_id)
@key = Key.find_by(id: key_id)
......
......@@ -375,6 +375,10 @@ class User < ApplicationRecord
Ci::DropPipelineService.new.execute_async_for_all(user.pipelines, :user_blocked, user)
Ci::DisableUserPipelineSchedulesService.new.execute(user)
end
after_transition any => :deactivated do |user|
NotificationService.new.user_deactivated(user.name, user.notification_email)
end
# rubocop: enable CodeReuse/ServiceClass
end
......
......@@ -428,6 +428,10 @@ class NotificationService
mailer.user_admin_rejection_email(name, email).deliver_later
end
def user_deactivated(name, email)
mailer.user_deactivated_email(name, email).deliver_later
end
# Members
def new_access_request(member)
return true unless member.notifiable?(:subscription)
......
= email_default_heading(_('Hello %{name},') % { name: @name })
%p
= _('Your account has been deactivated. You will not be able to: ')
%ul
%li
= _('Access Git repositories or the API.')
%li
= _('Receive any notifications from GitLab.')
%li
= _('Use slash commands.')
%p
- gitlab_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: root_url }
- link_end = '</a>'.html_safe
= _('To reactivate your account, %{gitlab_link_start}sign in to GitLab.%{link_end}').html_safe % { gitlab_link_start: gitlab_link_start, link_end: link_end}
%p
= _('Please contact your GitLab administrator if you think this is an error.')
<%= _('Hello %{name},') % { name: @name } %>
<%= _('Your account has been deactivated. You will not be able to: ') %>
- <%= _('Access Git repositories or the API.') %>
- <%= _('Receive any notifications from GitLab.') %>
- <%= _('Use slash commands.') %>
<%= _('To reactivate your account, sign in to GitLab at %{gitlab_url}.') % { gitlab_url: root_url } %>
<%= _('Please contact your GitLab administrator if you think this is an error.') %>
......@@ -1699,6 +1699,9 @@ msgstr ""
msgid "Access Git repositories"
msgstr ""
msgid "Access Git repositories or the API."
msgstr ""
msgid "Access Tokens"
msgstr ""
......@@ -26849,6 +26852,9 @@ msgstr ""
msgid "Receive alerts from manually configured Prometheus servers."
msgstr ""
msgid "Receive any notifications from GitLab."
msgstr ""
msgid "Receive notifications about your own activity"
msgstr ""
......@@ -34147,6 +34153,12 @@ msgstr ""
msgid "To protect this issue's confidentiality, a private fork of this project was selected."
msgstr ""
msgid "To reactivate your account, %{gitlab_link_start}sign in to GitLab.%{link_end}"
msgstr ""
msgid "To reactivate your account, sign in to GitLab at %{gitlab_url}."
msgstr ""
msgid "To receive alerts from manually configured Prometheus services, add the following URL and Authorization key to your Prometheus webhook config file. Learn more about %{linkStart}configuring Prometheus%{linkEnd} to send alerts to GitLab."
msgstr ""
......@@ -35418,6 +35430,9 @@ msgstr ""
msgid "Use shortcuts"
msgstr ""
msgid "Use slash commands."
msgstr ""
msgid "Use template"
msgstr ""
......@@ -37788,9 +37803,15 @@ msgstr ""
msgid "Your access request to the %{source_type} has been withdrawn."
msgstr ""
msgid "Your account has been deactivated"
msgstr ""
msgid "Your account has been deactivated by your administrator. Please log back in to reactivate your account."
msgstr ""
msgid "Your account has been deactivated. You will not be able to: "
msgstr ""
msgid "Your account is locked."
msgstr ""
......
......@@ -1898,6 +1898,14 @@ RSpec.describe User do
expect(user.deactivated?).to be_truthy
end
it 'sends deactivated user an email' do
expect_next_instance_of(NotificationService) do |notification|
allow(notification).to receive(:user_deactivated).with(user.name, user.notification_email)
end
user.deactivate
end
end
context "a user who is blocked" do
......
......@@ -2619,6 +2619,16 @@ RSpec.describe NotificationService, :mailer do
end
end
describe '#user_deactivated', :deliver_mails_inline do
let_it_be(:user) { create(:user) }
it 'sends the user an email' do
notification.user_deactivated(user.name, user.notification_email)
should_only_email(user)
end
end
describe 'GroupMember', :deliver_mails_inline do
let(:added_user) { create(:user) }
......
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