diff --git a/app/controllers/auth/confirmations_controller.rb b/app/controllers/auth/confirmations_controller.rb index a888253fd..3123285d7 100644 --- a/app/controllers/auth/confirmations_controller.rb +++ b/app/controllers/auth/confirmations_controller.rb @@ -8,9 +8,7 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController set_flash_message!(:notice, :confirmed) if resource.sign_in_count.zero? token = resource.send(:set_reset_password_token) - base = public_send("edit_#{resource_class.name.underscore}_password_url") - url = "#{base}?reset_password_token=#{token}" - redirect_to url + redirect_to controller: "auth/passwords", action: "edit", reset_password_token: token, confirmation: true else respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) } end diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index 3ce603ade..d4c63a4a8 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -24,6 +24,7 @@ class Auth::PasswordsController < Devise::PasswordsController def edit super + @confirmation = params["confirmation"] render "devise/passwords/reset_password" end diff --git a/app/views/devise/passwords/reset_password.html.erb b/app/views/devise/passwords/reset_password.html.erb index f66ca4240..c0b157dae 100644 --- a/app/views/devise/passwords/reset_password.html.erb +++ b/app/views/devise/passwords/reset_password.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, resource.sign_in_count.zero? ? "Set your password" : "Reset your password" %> +<% content_for :title, @confirmation ? "Set your password" : "Reset your password" %> <% content_for :before_content do %> <%= govuk_back_link( diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 8fa8d8ffa..8a501a8c8 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -58,7 +58,7 @@ en: messages: already_confirmed: "Email has already been confirmed. Sign in." blank: "Email can’t be blank" - confirmation: "Passwords don’t match" + confirmation: "Password confirmation doesn’t match new password" confirmation_period_expired: "Email needs to be confirmed within %{period}. Request a new account." expired: "Token has expired. Request a new token." not_found: "was not found" diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 4e9b531cc..e021e0727 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -15,6 +15,7 @@ FactoryBot.define do trait :support do role { "support" } end + sign_in_count { 5 } confirmed_at { Time.zone.now } created_at { Time.zone.now } updated_at { Time.zone.now } diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index ddf38c72e..8350671c9 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -5,7 +5,7 @@ RSpec.describe "User Features" do include Helpers let(:organisation) { user.organisation } let(:org_id) { organisation.id } - let(:set_password_template_id) { User::SET_PASSWORD_TEMPLATE_ID } + let(:set_password_template_id) { User::CONFIRMABLE_TEMPLATE_ID } let(:notify_client) { instance_double(Notifications::Client) } let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" } let(:devise_notify_mailer) { DeviseNotifyMailer.new }