diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index db9bb16a..7da10e1e 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -6,8 +6,11 @@ * Add autofocus to default views (by @Radagaisus) * Support Mongoid 3 onwards (by @durran) * Unlock user on password reset (by @marcinb) + * Allow validation callbacks to apply to virtual attributes (by @latortuga) + * Support alternate sign in error message when email record does not exist (@gabetax) * bug fix + * Fix default email_regexp config to not allow spaces (by @kukula) * Fix a regression introduced on warden 1.2.1 (by @ejfinneran) * Properly camelize omniauth strategies (by @saizai) * Do not set flash messages for non navigational requests on session sign out (by @mathieul) diff --git a/config/locales/en.yml b/config/locales/en.yml index 824c4ce8..4572f2ef 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,8 +18,8 @@ en: unauthenticated: 'You need to sign in or sign up before continuing.' unconfirmed: 'You have to confirm your account before continuing.' locked: 'Your account is locked.' + not_found_in_database: 'Invalid email or password.' invalid: 'Invalid email or password.' - invalid_email: 'Invalid email or password.' invalid_token: 'Invalid authentication token.' timeout: 'Your session expired, please sign in again to continue.' inactive: 'Your account was not activated yet.' diff --git a/lib/devise/strategies/database_authenticatable.rb b/lib/devise/strategies/database_authenticatable.rb index 78d95812..bccebb25 100644 --- a/lib/devise/strategies/database_authenticatable.rb +++ b/lib/devise/strategies/database_authenticatable.rb @@ -6,7 +6,7 @@ module Devise class DatabaseAuthenticatable < Authenticatable def authenticate! resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash) - return fail(:invalid_email) unless resource + return fail(:not_found_in_database) unless resource if validate(resource){ resource.valid_password?(password) } resource.after_database_authentication diff --git a/test/integration/database_authenticatable_test.rb b/test/integration/database_authenticatable_test.rb index 39c2e2cd..4bdf10ee 100644 --- a/test/integration/database_authenticatable_test.rb +++ b/test/integration/database_authenticatable_test.rb @@ -53,7 +53,7 @@ class DatabaseAuthenticationTest < ActionController::IntegrationTest end test 'sign in with invalid email should return to sign in form with error message' do - store_translations :en, :devise => { :failure => { :admin => { :invalid_email => 'Invalid email address' } } } do + store_translations :en, :devise => { :failure => { :admin => { :not_found_in_database => 'Invalid email address' } } } do sign_in_as_admin do fill_in 'email', :with => 'wrongemail@test.com' end