Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

handle password confirmation mismatched #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
de:
errors:
messages:
password_confirmation_mismatched: "nicht übereinstimmend."
taken_in_past: "wurde bereits in der Vergangenheit verwendet!"
equal_to_current_password: "darf nicht dem aktuellen Passwort entsprechen!"
password_format: "müssen große, kleine Buchstaben und Ziffern enthalten"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
en:
errors:
messages:
password_confirmation_mismatched: "mismatched."
taken_in_past: "was used previously."
equal_to_current_password: "must be different than the current password."
password_format: "must contain big, small letters and digits"
Expand Down
1 change: 1 addition & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
es:
errors:
messages:
password_confirmation_mismatched: "no coinciden."
taken_in_past: "la contraseña fue usada previamente, favor elegir otra."
equal_to_current_password: "tiene que ser diferente a la contraseña actual."
password_format: "tiene que contener mayúsculas, minúsculas y digitos "
Expand Down
1 change: 1 addition & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
it:
errors:
messages:
password_confirmation_mismatched: "non corrispondenti."
taken_in_past: "e' stata gia' utilizzata in passato!"
equal_to_current_password: " deve essere differente dalla password corrente!"
devise:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ def update_with_password(params, *options)
new_password = params[:password]
new_password_confirmation = params[:password_confirmation]

result = if valid_password?(current_password) && new_password.present? && new_password_confirmation.present?
result = if valid_password?(current_password) && new_password.present? && new_password_confirmation.present? && new_password_confirmation == new_password
update_attributes(params, *options)
else
self.assign_attributes(params, *options)
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
self.errors.add(:password, new_password.blank? ? :blank : :invalid)
self.errors.add(:password_confirmation, new_password_confirmation.blank? ? :blank : :invalid)
new_password_confirmation_error = if new_password_confirmation.blank?
:blank
elsif new_password != new_password_confirmation
I18n.t('errors.messages.password_confirmation_mismatched')
else
:invalid
end
self.errors.add(:password_confirmation, new_password_confirmation_error)
false
end

Expand Down