docbrown/app/models/email_authorization.rb
Jacob Herrington a4f71c22b6
[deploy] Add automated email ownership emails (#7556)
* Add automated email ownership emails

This is task Michael does manually a lot. There are a lot of cases where
we need to validate that an individual has access to the email address
associated with their DEV account. This automates a singificant portion
of that, and hopefully we can use it in a lot of places.
2020-05-06 12:07:54 -05:00

20 lines
604 B
Ruby

class EmailAuthorization < ApplicationRecord
before_create :generate_confirmation_token
belongs_to :user
TYPES = %w[merge_request account_lockout uuid_issue account_ownership].freeze
# uuid_issue is a specific case where a user deletes their old auth account and recreates it, leaving us with the incorrect uuid
validates :type_of, presence: true
validates :type_of, inclusion: { in: TYPES }
alias_attribute :sent_at, :created_at
private
def generate_confirmation_token
return if confirmation_token.present?
self.confirmation_token = SecureRandom.urlsafe_base64
end
end