diff --git a/app/views/devise/mailer/_password_change_forgotten.html.erb b/app/views/devise/mailer/_password_change_forgotten.html.erb new file mode 100644 index 000000000..894cbda1d --- /dev/null +++ b/app/views/devise/mailer/_password_change_forgotten.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password. You can do this through the link below.

+ +

<%= govuk_link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/_password_change_initial.html.erb b/app/views/devise/mailer/_password_change_initial.html.erb new file mode 100644 index 000000000..6645c7c77 --- /dev/null +++ b/app/views/devise/mailer/_password_change_initial.html.erb @@ -0,0 +1,6 @@ +

Hello <%= @resource.name %>!

+ +

An account has been created for you to submit CORE data on behalf of @resource.organisation.

+ +

Your username is <% @resource.email %>, use the link below to set your password. +

<%= govuk_link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb index 894cbda1d..dd4412b35 100644 --- a/app/views/devise/mailer/reset_password_instructions.html.erb +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -1,8 +1,5 @@ -

Hello <%= @resource.email %>!

- -

Someone has requested a link to change your password. You can do this through the link below.

- -

<%= govuk_link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

- -

If you didn't request this, please ignore this email.

-

Your password won't change until you access the link above and create a new one.

+<% if @resource.last_sign_in_at.nil? %> + <%= render partial: "password_change_initial" %> +<% else %> + <%= render partial: "password_change_forgotten" %> +<% end %> diff --git a/spec/requests/auth/passwords_controller_spec.rb b/spec/requests/auth/passwords_controller_spec.rb index 947355298..7bb617f78 100644 --- a/spec/requests/auth/passwords_controller_spec.rb +++ b/spec/requests/auth/passwords_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Auth::PasswordsController, type: :request do end context "when a password reset is requested the email" do - let(:user) { FactoryBot.create(:user) } + let(:user) { FactoryBot.create(:user, last_sign_in_at: Time.zone.now) } let(:email) { user.email } it "should contain the correct email" do