diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index b48093f87c0..54cfaddb588 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -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) + analytics.track_event(Analytics::PROFILE_ENCRYPTION_INVALID, error: err.message) + end end end diff --git a/app/models/concerns/user_encrypted_attribute_overrides.rb b/app/models/concerns/user_encrypted_attribute_overrides.rb index 4abaa71b73c..ae5670e1115 100644 --- a/app/models/concerns/user_encrypted_attribute_overrides.rb +++ b/app/models/concerns/user_encrypted_attribute_overrides.rb @@ -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)