From dcf980a22b3967c95c8cabddbab5b0a4f5a1e106 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:32:10 +0000 Subject: [PATCH] CLDC-2830 Update devise error messages (#2042) * Update error messages * Udate invalid token message * Update validation/error message order for password --- app/models/user.rb | 2 +- config/locales/devise.en.yml | 2 +- config/locales/en.yml | 4 +++- spec/requests/auth/passwords_controller_spec.rb | 2 +- spec/requests/users_controller_spec.rb | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7042034b4..135d85428 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,8 +15,8 @@ class User < ApplicationRecord validates :email, uniqueness: { allow_blank: true, case_sensitive: true, if: :will_save_change_to_email? } validates :email, format: { with: Devise.email_regexp, allow_blank: true, if: :will_save_change_to_email? } validates :password, presence: { if: :password_required? } - validates :password, confirmation: { if: :password_required? } validates :password, length: { within: Devise.password_length, allow_blank: true } + validates :password, confirmation: { if: :password_required? } after_validation :send_data_protection_confirmation_reminder, if: :is_dpo_changed? diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 16299ea10..e40af1d37 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -62,7 +62,7 @@ en: messages: already_confirmed: "Email has already been confirmed. Sign in." blank: "can’t be blank" - confirmation: "Password confirmation doesn’t match new password" + confirmation: "The passwords you entered do not match. Try again." confirmation_period_expired: "Email needs to be confirmed within %{period}. Request a new link below." expired: "Token has expired. Request a new token." not_found: "was not found" diff --git a/config/locales/en.yml b/config/locales/en.yml index 69a4a8bb9..b420e3088 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -164,7 +164,9 @@ en: blank: "Select role" password: blank: Enter a password - too_short: Password is too short (minimum is %{count} characters) + too_short: The password you entered is too short. Enter a password that is %{count} characters or longer. + reset_password_token: + invalid: "That link is invalid. Check you are using the correct link." merge_request: attributes: absorbing_organisation_id: diff --git a/spec/requests/auth/passwords_controller_spec.rb b/spec/requests/auth/passwords_controller_spec.rb index 29a032395..92c36608c 100644 --- a/spec/requests/auth/passwords_controller_spec.rb +++ b/spec/requests/auth/passwords_controller_spec.rb @@ -107,7 +107,7 @@ RSpec.describe Auth::PasswordsController, type: :request do put "/account/password", headers: headers, params: params expect(response).to have_http_status(:unprocessable_entity) expect(page).to have_css("h1", text: "Reset your password") - expect(page).to have_content("doesn’t match new password") + expect(page).to have_content("passwords you entered do not match") end end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 958f2187a..aad0b9f28 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -67,7 +67,7 @@ RSpec.describe UsersController, type: :request do expect(response).to have_http_status(:unprocessable_entity) expect(page).to have_css("h1", class: "govuk-heading-l", text: "Change your password") expect(page).to have_selector("#error-summary-title") - expect(page).to have_content("Password confirmation doesn’t match new password") + expect(page).to have_content("passwords you entered do not match") end end end