fix: downcase email before finding (#8921)
* fix: downcase email when finding * feat: add `from_email` class * refactor: use `from_email` * feat: add rule to disallow find_by email directly * chore: remove redundant test Since the previous imlpmentation didn't do a case-insentive search, a new user would be created, and the error would be raised at the DB layer. With the new changes, this test case is redundant * refactor: use from_email
This commit is contained in:
@@ -165,6 +165,12 @@ class Contact < ApplicationRecord
|
||||
email_format
|
||||
end
|
||||
|
||||
def self.from_email(email)
|
||||
# rubocop:disable UseFromEmail,Migration/DepartmentName
|
||||
find_by(email: email.downcase)
|
||||
# rubocop:enable UseFromEmail,Migration/DepartmentName
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ip_lookup
|
||||
|
||||
@@ -156,6 +156,12 @@ class User < ApplicationRecord
|
||||
mutations_from_database.changed?('email')
|
||||
end
|
||||
|
||||
def self.from_email(email)
|
||||
# rubocop:disable UseFromEmail,Migration/DepartmentName
|
||||
find_by(email: email.downcase)
|
||||
# rubocop:enable UseFromEmail,Migration/DepartmentName
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_macros
|
||||
|
||||
Reference in New Issue
Block a user