Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hash invalid passwords twice #5655

Open
wants to merge 1 commit into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/devise/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Devise::SessionsController < DeviseController

# GET /resource/sign_in
def new
self.resource = resource_class.new(sign_in_params)
self.resource = resource_class.new(sign_in_params.except('password'))
clean_up_passwords(resource)
yield resource if block_given?
respond_with(resource, serialize_options(resource))
Expand Down
23 changes: 23 additions & 0 deletions test/integration/database_authenticatable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
assert_not warden.authenticated?(:admin)
end

test 'sign in with invalid credentials should not invoke Devise::Encryptor.digest' do
module ::Devise::Encryptor
class << self
alias original_digest digest

def digest(klass, password)
raise 'Devise::Encryptor.digest should not be called here.'
end
end
end

visit_with_option nil, new_user_session_path
fill_in 'email', with: 'user@test.com'
fill_in 'password', with: 'abcdef'
click_button 'Log In'

module ::Devise::Encryptor
class << self
alias digest original_digest
end
end
end

test 'when in paranoid mode and without a valid e-mail' do
swap Devise, paranoid: true do
store_translations :en, devise: { failure: { not_found_in_database: 'Not found in database' } } do
Expand Down