mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Merge pull request #2147 from gabetax/signin_nonexistent_error
Support alternate sign in error message when email record does not exist
This commit is contained in:
commit
cbfdcbeaed
3 changed files with 9 additions and 6 deletions
|
@ -19,6 +19,7 @@ en:
|
|||
unconfirmed: 'You have to confirm your account before continuing.'
|
||||
locked: 'Your account is locked.'
|
||||
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.'
|
||||
|
|
|
@ -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) unless resource
|
||||
return fail(:invalid_email) unless resource
|
||||
|
||||
if validate(resource){ resource.valid_password?(password) }
|
||||
resource.after_database_authentication
|
||||
|
|
|
@ -53,12 +53,14 @@ class DatabaseAuthenticationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'sign in with invalid email should return to sign in form with error message' do
|
||||
sign_in_as_admin do
|
||||
fill_in 'email', :with => 'wrongemail@test.com'
|
||||
end
|
||||
store_translations :en, :devise => { :failure => { :admin => { :invalid_email => 'Invalid email address' } } } do
|
||||
sign_in_as_admin do
|
||||
fill_in 'email', :with => 'wrongemail@test.com'
|
||||
end
|
||||
|
||||
assert_contain 'Invalid email or password'
|
||||
assert_not warden.authenticated?(:admin)
|
||||
assert_contain 'Invalid email address'
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
|
||||
test 'sign in with invalid pasword should return to sign in form with error message' do
|
||||
|
|
Loading…
Add table
Reference in a new issue