Skip to content

Commit

Permalink
Merge pull request #2381 from alphagov/update-email-text
Browse files Browse the repository at this point in the history
Update suspension and unlock email text
  • Loading branch information
chrislo committed Sep 29, 2023
2 parents 243f9eb + f8021af commit 4fb3d71
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 50 deletions.
6 changes: 1 addition & 5 deletions app/mailers/mailer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ def email_from
end

def app_name
if GovukEnvironment.production?
I18n.t("mailer.app_name.no_instance")
else
I18n.t("mailer.app_name.instance", instance_name: GovukEnvironment.name)
end
I18n.t("mailer.app_name.instance", instance_name: GovukEnvironment.name)
end

def email_from_address
Expand Down
12 changes: 6 additions & 6 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ def locked_time
end

def unlock_time
(@user.locked_at + 1.hour).to_fs(:govuk_date)
t = (@user.locked_at + User.unlock_in)
time_part = t.to_fs(:govuk_time)
date_part = t.to_date.to_fs(:govuk_date)

"#{time_part} UK time on #{date_part}"
end

def account_name
if GovukEnvironment.production?
"account"
else
"#{GovukEnvironment.name} account"
end
"#{GovukEnvironment.name} account"
end

def subject_for(key)
Expand Down
16 changes: 7 additions & 9 deletions app/views/user_mailer/suspension_notification.text.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<%= t('department.name') %> Signon accounts are suspended after <%= User::SUSPENSION_THRESHOLD_PERIOD.inspect %> of inactivity.
Your <%= t('department.name') %> Signon <%= account_name %> for <%= @user.email %> is now suspended.

Your <%= t('department.name') %> Signon <%= account_name %>, for <%= @user.email %>, has now been suspended and you won't be able to access any <%= t('department.name') %> <%= account_name %> publishing applications.
^ Please do not reply to this email.

<% unless GovukEnvironment.production? %>
<%= account_name.humanize %> suspensions do not suspend production accounts or remove access to <%= t('department.name') %> production applications.
<% end %>
## How to reactive your account

If you don't need the account you can ignore this email.
Contact your managing editor or user manager ‒ they can unsuspend your account.

If you do still need the account you will have to contact a managing <%= t('department.name') %> editor in your organisation (or your parent organisation). They can use the support form (<%= t('support.url') %>) to get help from the <%= t('department.name') %> team.
## If you’re a managing editor or user manager

Read our blog post about suspending unused <%= t('department.name') %> accounts:
Contact another managing editor or user manager and ask them to unsuspend you.

https://insidegovuk.blog.gov.uk/2014/08/21/suspending-unused-gov-uk-accounts
Please note that managing editors in an arm's length body may not have this authority.
25 changes: 15 additions & 10 deletions app/views/user_mailer/suspension_reminder.text.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<%= t('department.name') %> Signon accounts are suspended after <%= User::SUSPENSION_THRESHOLD_PERIOD.inspect %> of inactivity.
Your <%= t('department.name') %> Signon <%= account_name %>, for <%= @user.email %> will be suspended <%= suspension_time %>.

Your <%= t('department.name') %> Signon <%= account_name %>, for <%= @user.email %>, will be suspended <%= suspension_time %>. After suspension you won't be able to access any <%= t('department.name') %> <%= account_name %> publishing applications.

<% unless GovukEnvironment.production? %>
<%= account_name.humanize %> suspensions do not suspend production accounts or remove access to <%= t('department.name') %> production applications.
<% if GovukEnvironment.production? %>
If this happens you won’t be able to access any of your publishing apps from this account, including Whitehall and Publisher.
<% else %>
If this happens you won’t be able to do any training from this account.
<% end %>

If you don't need the account you can ignore these emails.
## How to stop suspension

To stop your account suspension you will need to sign in:
^ Please do not reply to this email.

To stop your account being suspended, all you have to do is sign in:
<%= new_user_session_url(protocol: 'https') %>
If you’ve forgotten your password, you can request a new one from the sign in screen.
<%= t('department.name') %> Signon accounts are automatically suspended after <%= User::SUSPENSION_THRESHOLD_PERIOD.inspect %> of inactivity.

Read our blog post about suspending unused <%= t('department.name') %> accounts:
<% unless GovukEnvironment.production? %>
Please note that Integration account suspensions do not suspend Production accounts.

Find about more about the two kinds of accounts on the [How to Publish on GOV.UK page](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/introduction-and-access-to-whitehall-publisher).
<% end %>

https://insidegovuk.blog.gov.uk/2014/08/21/suspending-unused-gov-uk-accounts
If you no longer need this account, please ignore these instructions.
16 changes: 11 additions & 5 deletions app/views/user_mailer/unlock_instructions.text.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Your <%= t('department.name') %> Signon <%= account_name %>, for <%= @user.email %>, was locked at <%= locked_time %> because the wrong sign on details were entered too many times.
Your <%= t('department.name') %> Signon <%= account_name %>, for <%= @user.email %> has been locked.

<% unless GovukEnvironment.production? %>
<%= account_name.humanize %> locks do not lock production accounts.
<% end %>
This has happened because the wrong sign in details were entered too many times.

Your account will be unlocked at <%= unlock_time %>. If you need your account unlocked sooner, please contact a managing <%= t('department.name') %> editor in your organisation (or your parent organisation). They can use the support form (<%= t('support.url') %>) to get help from the <%= t('department.name') %> team.
## What happens now

Your account will be unlocked at <%= unlock_time %> UK time.

## If you need your account to be unlocked immediately

Please contact a GOV.UK managing editor or user manager in your organisation (or parent organisation) for further assistance.

Please note that managing editors in an arm’s length body may not have the authority to unlock.
3 changes: 2 additions & 1 deletion test/models/noisy_batch_invitation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class NoisyBatchInvitationTest < ActionMailer::TestCase
context "work correctly in production environment" do
setup do
GovukEnvironment.stubs(:production?).returns(true)
GovukEnvironment.stubs(:name).returns("production")

user = create(:user, name: "Bob Loblaw")
@batch_invitation = create(:batch_invitation, user:)
Expand All @@ -61,7 +62,7 @@ class NoisyBatchInvitationTest < ActionMailer::TestCase
end

should "from address should not include the environment name" do
assert_match(/".* Signon" <noreply-signon@.*\.gov\.uk>/, @email[:from].to_s)
assert_match(/".* Signon production" <noreply-signon@.*\.gov\.uk>/, @email[:from].to_s)
end
end
end
16 changes: 2 additions & 14 deletions test/models/user_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ def assert_support_present_in_text(link_text, email = @email)
should "say 'suspended' in the body" do
assert_body_includes "suspended"
end

should "include support links" do
assert_support_present_in_text "support form"
end
end

context "on a non-production Signon instance" do
Expand All @@ -160,7 +156,7 @@ def assert_support_present_in_text(link_text, email = @email)
setup do
GovukEnvironment.stubs(:production?).returns(false)
GovukEnvironment.stubs(:name).returns("test")
@the_time = Time.zone.now
@the_time = Time.zone.parse("2023-10-31 02:00:00")
user = User.new(name: "User", email: "user@example.com", locked_at: @the_time)
@email = UserMailer.unlock_instructions(user, "afaketoken")
end
Expand All @@ -170,16 +166,8 @@ def assert_support_present_in_text(link_text, email = @email)
assert_body_includes "for user@example.com"
end

should "state when the account was locked" do
assert_body_includes "was locked at #{@the_time.to_fs(:govuk_date)}"
end

should "state when the account will be unlocked" do
assert_body_includes "Your account will be unlocked at #{(@the_time + 1.hour).to_fs(:govuk_date)}"
end

should "include correct support links" do
assert_support_present_in_text "support form"
assert_body_includes "Your account will be unlocked at 3:00am UK time on 31 October 2023"
end
end

Expand Down

0 comments on commit 4fb3d71

Please sign in to comment.