mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
Add verification methods
This commit is contained in:
parent
cc142076c3
commit
9ae85f3d74
2 changed files with 12 additions and 2 deletions
|
@ -3,12 +3,12 @@ module Concerns
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def email_verification
|
||||
EmailAddressVerification.find_by(email: self.email)
|
||||
EmailAddressVerification.find_or_create_by(email: self.email)
|
||||
end
|
||||
|
||||
def billing_email_verification
|
||||
if self.attribute_names.include?('billing_email')
|
||||
EmailAddressVerification.find_by(email: self.billing_email)
|
||||
EmailAddressVerification.find_or_create_by(email: self.billing_email)
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
class EmailAddressVerification < ApplicationRecord
|
||||
|
||||
RECENTLY_VERIFIED_PERIOD = 1.month
|
||||
|
||||
def recently_verified?
|
||||
verified_at > Time.zone.now - RECENTLY_VERIFIED_PERIOD
|
||||
end
|
||||
|
||||
def verify
|
||||
validation_request = Truemail.validate(email)
|
||||
|
||||
update(verified_at: Time.zone.now) if validation_request.result.success
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue