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
1 change: 1 addition & 0 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def check_user_needs_redirect
if user_fully_authenticated?
redirect_to signed_in_url
elsif current_user
analytics.partial_authentication_log_out
sign_out
end
end
Expand Down
7 changes: 7 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2949,6 +2949,13 @@ def otp_phone_validation_failed(error:, context:, country:, **extra)
)
end

def partial_authentication_log_out(**extra)
track_event(
'Partially authenticated user logged out',
**extra,
)
end

# @param [Boolean] success
# @param [Hash] errors
# The user updated their password
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/users/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

describe 'GET /users/sign_in' do
it 'clears the session when user is not yet 2fa-ed' do
stub_analytics
expect(@analytics).to receive(:track_event).with(
'Sign in page visited',
flash: nil,
stored_location: nil,
)
expect(@analytics).to receive(:track_event).with('Partially authenticated user logged out')
sign_in_before_2fa

get :new
Expand Down