* Add missing presence validator for Tag * Add missing presence validators to Follow * Add missing presence validators to ProfileField * Add missing presence validators to Comment * Add missing presence validators to Profile * Add missing presence validators to Organization * Add missing presence validators to Badge * Add missing presence validators to Webhook::Endpoint * Add missing presence validators to NotificationSubscription * Add missing presence validators to PodcastEpisode * Add missing presence validators to Sponsorship * Add missing presence validators to PollOption * Add missing presence validators to Poll * Add missing presence validators to Article * Add missing presence validators to EmailAuthorization * Add missing presence validators to AuditLog * Add missing presence validators to DataUpdateScript * Add missing presence validators to User * Add missing presence validators to SiteConfig * Fix specs
21 lines
588 B
Ruby
21 lines
588 B
Ruby
class EmailAuthorization < ApplicationRecord
|
|
belongs_to :user
|
|
|
|
# uuid_issue is a specific case where a user deletes their old auth account and recreates it,
|
|
# leaving us with the incorrect uuid
|
|
TYPES = %w[merge_request account_lockout uuid_issue account_ownership].freeze
|
|
|
|
validates :type_of, presence: true, inclusion: { in: TYPES }
|
|
|
|
alias_attribute :sent_at, :created_at
|
|
|
|
before_create :generate_confirmation_token
|
|
|
|
private
|
|
|
|
def generate_confirmation_token
|
|
return if confirmation_token.present?
|
|
|
|
self.confirmation_token = SecureRandom.urlsafe_base64
|
|
end
|
|
end
|