OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[39736] Better password confirmation message
Oliver Günthera93b065971a2
diff --git a/app/models/user.rb b/app/models/user.rbindex c92d606e594..9fceb1fcb05 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -97,21 +97,26 @@ class User < Principalattr_accessor :password, :password_confirmation, :last_before_login_on- validates_presence_of :login,+ validates :login,:firstname,:lastname,:mail,- unless: Proc.new { |user| user.builtin? }+ presence: { unless: Proc.new { |user| user.builtin? } }- validates_uniqueness_of :login, if: Proc.new { |user| !user.login.blank? }, case_sensitive: false- validates_uniqueness_of :mail, allow_blank: true, case_sensitive: false+ validates :login, uniqueness: { if: Proc.new { |user| !user.login.blank? }, case_sensitive: false }+ validates :mail, uniqueness: { allow_blank: true, case_sensitive: false }# Login must contain letters, numbers, underscores only- validates_format_of :login, with: /\A[a-z0-9_\-@.+ ]*\z/i- validates_length_of :login, maximum: 256- validates_length_of :firstname, :lastname, maximum: 256+ validates :login, format: { with: /\A[a-z0-9_\-@.+ ]*\z/i }+ validates :login, length: { maximum: 256 }+ validates :firstname, :lastname, length: { maximum: 256 }validates :mail, email: true, unless: Proc.new { |user| user.mail.blank? }- validates_length_of :mail, maximum: 256, allow_nil: true- validates_confirmation_of :password, allow_nil: true+ validates :mail, length: { maximum: 256, allow_nil: true }++ validates :password,+ confirmation: {+ allow_nil: true,+ message: ->(*) { I18n.t('activerecord.errors.models.user.attributes.password_confirmation.confirmation') }+ }auto_strip_attributes :login, nullify: falseauto_strip_attributes :mail, nullify: falsediff --git a/config/locales/en.yml b/config/locales/en.ymlindex 9dd250b9dee..df762ff26bf 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -806,6 +806,9 @@ en:group_without_name: "Unnamed groups are not allowed."user:attributes:+ password_confirmation:+ confirmation: "Password confirmation does not match password."+ format: "%{message}"password:weak: "Must contain characters of the following classes (at least %{min_count} of %{all_count}): %{rules}."lowercase: "lowercase (e.g. 'a')"diff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rbindex 11e25275a77..e35acc0c1dc 100644--- a/spec/controllers/my_controller_spec.rb+++ b/spec/controllers/my_controller_spec.rb@@ -71,7 +71,8 @@ describe MyController, type: :controller doassert_response :successassert_template 'password'expect(user.errors.attribute_names).to eq([:password_confirmation])- expect(user.errors.map(&:message).flatten.join('')).to include("doesn't match")+ expect(user.errors.map(&:message).flatten)+ .to contain_exactly("Password confirmation does not match password.")endenddiff --git a/spec/features/users/self_registration_spec.rb b/spec/features/users/self_registration_spec.rbindex 71d02bdbc22..ccdfee231f7 100644--- a/spec/features/users/self_registration_spec.rb+++ b/spec/features/users/self_registration_spec.rb@@ -80,7 +80,7 @@ describe 'user self registration', type: :feature, js: true doendexpect(page)- .to have_content('Confirmation doesn\'t match Password')+ .to have_content('Password confirmation does not match password.')# correcting passwordwithin '.registration-modal' do