Add User#email_domain method to extract domain from email address (#35159)
This commit is contained in:
1 parent
8ba1487f30
commit
f852da50f6
5 files changed
+38
-3
No files matched your search
@@ -163,6 +163,7 @@ class Account < ApplicationRecord
|
||||
after_update_commit :trigger_update_webhooks
|
||||
|
||||
delegate :email,
|
||||
:email_domain,
|
||||
:unconfirmed_email,
|
||||
:current_sign_in_at,
|
||||
:created_at,
|
||||
|
||||
@@ -223,6 +223,12 @@ class User < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def email_domain
|
||||
Mail::Address.new(email).domain
|
||||
rescue Mail::Field::ParseError
|
||||
nil
|
||||
end
|
||||
|
||||
def update_sign_in!(new_sign_in: false)
|
||||
old_current = current_sign_in_at
|
||||
new_current = Time.now.utc
|
||||
|
||||
Reference in new issue
Block a user