Commit e2ad397f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'email-user-when-blocked' into 'master'

Email user when account deactivated

See merge request gitlab-org/gitlab!64964
parents f3b31253 461a2845
...@@ -26,6 +26,14 @@ module Emails ...@@ -26,6 +26,14 @@ module Emails
subject: subject(_("GitLab account request rejected"))) subject: subject(_("GitLab account request rejected")))
end 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 # rubocop: disable CodeReuse/ActiveRecord
def new_ssh_key_email(key_id) def new_ssh_key_email(key_id)
@key = Key.find_by(id: key_id) @key = Key.find_by(id: key_id)
......
...@@ -375,6 +375,10 @@ class User < ApplicationRecord ...@@ -375,6 +375,10 @@ class User < ApplicationRecord
Ci::DropPipelineService.new.execute_async_for_all(user.pipelines, :user_blocked, user) Ci::DropPipelineService.new.execute_async_for_all(user.pipelines, :user_blocked, user)
Ci::DisableUserPipelineSchedulesService.new.execute(user) Ci::DisableUserPipelineSchedulesService.new.execute(user)
end end
after_transition any => :deactivated do |user|
NotificationService.new.user_deactivated(user.name, user.notification_email)
end
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
end end
......
...@@ -428,6 +428,10 @@ class NotificationService ...@@ -428,6 +428,10 @@ class NotificationService
mailer.user_admin_rejection_email(name, email).deliver_later mailer.user_admin_rejection_email(name, email).deliver_later
end end
def user_deactivated(name, email)
mailer.user_deactivated_email(name, email).deliver_later
end
# Members # Members
def new_access_request(member) def new_access_request(member)
return true unless member.notifiable?(:subscription) 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.') %>
...@@ -1704,6 +1704,9 @@ msgstr "" ...@@ -1704,6 +1704,9 @@ msgstr ""
msgid "Access Git repositories" msgid "Access Git repositories"
msgstr "" msgstr ""
msgid "Access Git repositories or the API."
msgstr ""
msgid "Access Tokens" msgid "Access Tokens"
msgstr "" msgstr ""
...@@ -26854,6 +26857,9 @@ msgstr "" ...@@ -26854,6 +26857,9 @@ msgstr ""
msgid "Receive alerts from manually configured Prometheus servers." msgid "Receive alerts from manually configured Prometheus servers."
msgstr "" msgstr ""
msgid "Receive any notifications from GitLab."
msgstr ""
msgid "Receive notifications about your own activity" msgid "Receive notifications about your own activity"
msgstr "" msgstr ""
...@@ -34152,6 +34158,12 @@ msgstr "" ...@@ -34152,6 +34158,12 @@ msgstr ""
msgid "To protect this issue's confidentiality, a private fork of this project was selected." msgid "To protect this issue's confidentiality, a private fork of this project was selected."
msgstr "" 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." 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 "" msgstr ""
...@@ -35423,6 +35435,9 @@ msgstr "" ...@@ -35423,6 +35435,9 @@ msgstr ""
msgid "Use shortcuts" msgid "Use shortcuts"
msgstr "" msgstr ""
msgid "Use slash commands."
msgstr ""
msgid "Use template" msgid "Use template"
msgstr "" msgstr ""
...@@ -37793,9 +37808,15 @@ msgstr "" ...@@ -37793,9 +37808,15 @@ msgstr ""
msgid "Your access request to the %{source_type} has been withdrawn." msgid "Your access request to the %{source_type} has been withdrawn."
msgstr "" 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." msgid "Your account has been deactivated by your administrator. Please log back in to reactivate your account."
msgstr "" msgstr ""
msgid "Your account has been deactivated. You will not be able to: "
msgstr ""
msgid "Your account is locked." msgid "Your account is locked."
msgstr "" msgstr ""
......
...@@ -1898,6 +1898,14 @@ RSpec.describe User do ...@@ -1898,6 +1898,14 @@ RSpec.describe User do
expect(user.deactivated?).to be_truthy expect(user.deactivated?).to be_truthy
end 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 end
context "a user who is blocked" do context "a user who is blocked" do
......
...@@ -2619,6 +2619,16 @@ RSpec.describe NotificationService, :mailer do ...@@ -2619,6 +2619,16 @@ RSpec.describe NotificationService, :mailer do
end end
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 describe 'GroupMember', :deliver_mails_inline do
let(:added_user) { create(:user) } 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