docbrown/app/models/email_authorization.rb
Andy Zhao a3728cfa4c
[deploy] Add EmailAuthorization model (#6335)
* Add EmailAuthorization model

* Add model file oops

* Add comment for uuid type

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-03-02 12:14:24 -05:00

12 lines
457 B
Ruby

class EmailAuthorization < ApplicationRecord
belongs_to :user
TYPES = %w[merge_request account_lockout uuid_issue].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 :json_data, :type_of, presence: true
validates :type_of, inclusion: { in: TYPES }
validates :user_id, uniqueness: { scope: %i[type_of] }
alias_attribute :sent_at, :created_at
end