mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-06 03:01:21 -04:00
Downcase authentication keys and humanize error message (#4834)
"Invalid Email or password." is grammatically incorrect, a change introduced a while ago by #4014. Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
This commit is contained in:
committed by
Carlos Antonio da Silva
parent
9a149ff139
commit
356b094312
@@ -111,11 +111,13 @@ module Devise
|
||||
options[:scope] = "devise.failure"
|
||||
options[:default] = [message]
|
||||
auth_keys = scope_class.authentication_keys
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key).downcase }
|
||||
options[:authentication_keys] = keys.join(I18n.t(:"support.array.words_connector"))
|
||||
options = i18n_options(options)
|
||||
|
||||
I18n.t(:"#{scope}.#{message}", **options)
|
||||
translated_message = I18n.t(:"#{scope}.#{message}", **options)
|
||||
# only call `#humanize` when the message is `:invalid` to ensure the original format
|
||||
# of other messages - like `:does_not_exist` - is kept.
|
||||
message == :invalid ? translated_message.humanize : translated_message
|
||||
else
|
||||
message.to_s
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user