Skip to content
Merged
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
5 changes: 2 additions & 3 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SessionsController < Devise::SessionsController
before_action :check_user_needs_redirect, only: [:new]
before_action :apply_secure_headers_override, only: [:new, :create]
before_action :clear_session_bad_password_count_if_window_expired, only: [:create]
before_action :update_devise_params_sanitizer, only: [:new]

def new
analytics.sign_in_page_visit(
Expand Down Expand Up @@ -240,8 +239,8 @@ def override_csp_for_google_analytics
request.content_security_policy = policy
end

def update_devise_params_sanitizer
devise_parameter_sanitizer.permit(:sign_in, except: [:email, :password]) if !request.post?
def sign_in_params
params[resource_name]&.permit(:email) if request.post?
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/users/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
sp_request_url_present: false,
remember_device: false,
}
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original

expect(@analytics).to receive(:track_event).
with('Email and Password Authentication', analytics_hash)
Expand All @@ -252,6 +253,7 @@
sp_request_url_present: false,
remember_device: false,
}
expect(SCrypt::Engine).to receive(:hash_secret).once.and_call_original
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any auth attempt, we want to run an scrypt hash exactly once.

This and the line above are helpful because they catch both the case where we may hash multiple times and the case where we hash zero times.


expect(@analytics).to receive(:track_event).
with('Email and Password Authentication', analytics_hash)
Expand Down