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
6 changes: 4 additions & 2 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ def cache_active_profile
begin
cacher.save(auth_params[:password], profile)
rescue Encryption::EncryptionError => err
profile.deactivate(:encryption_error)
analytics.track_event(Analytics::PROFILE_ENCRYPTION_INVALID, error: err.message)
if profile
profile.deactivate(:encryption_error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting that with this change, but no change to the specs, everything passes. I thought about going down this route originally, but the test was looking for a particular decryption error to get thrown, which couldn't come from this code since it gets rescued.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The error comes later. See my commit message.

analytics.track_event(Analytics::PROFILE_ENCRYPTION_INVALID, error: err.message)
end
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/models/concerns/user_encrypted_attribute_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def find_with_email(email)

email = email.downcase.strip
email_fingerprint = create_fingerprint(email)
resource = find_by(email_fingerprint: email_fingerprint)
resource if resource&.email == email
find_by(email_fingerprint: email_fingerprint)
end

def create_fingerprint(email)
Expand Down