mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
Add email & nonverified color to contact show
This commit is contained in:
parent
3d444c3a04
commit
48036c660d
5 changed files with 10 additions and 5 deletions
35
app/models/concerns/email_verifable.rb
Normal file
35
app/models/concerns/email_verifable.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Concerns
|
||||
module EmailVerifable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def email_verification
|
||||
EmailAddressVerification.find_or_create_by(email: email,
|
||||
domain: domain(email))
|
||||
end
|
||||
|
||||
def billing_email_verification
|
||||
return unless attribute_names.include?('billing_email')
|
||||
|
||||
EmailAddressVerification.find_or_create_by(email: billing_email,
|
||||
domain: domain(email))
|
||||
end
|
||||
|
||||
def domain(email)
|
||||
Mail::Address.new(email).domain || 'not_found'
|
||||
rescue Mail::Field::IncompleteParseError
|
||||
'not_found'
|
||||
end
|
||||
|
||||
def verify_email_mx_smtp(field:, email:)
|
||||
errors.add(field, :invalid) unless email.blank? || Truemail.valid?(email)
|
||||
end
|
||||
|
||||
def correct_email_format
|
||||
verify_email_mx_smtp(field: :email, email: email)
|
||||
end
|
||||
|
||||
def correct_billing_email_format
|
||||
verify_email_mx_smtp(field: :billing_email, email: billing_email)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue