tinyforms/app/models/user.rb
2020-04-28 01:40:06 +02:00

21 lines
551 B
Ruby

# frozen_string_literal: true
class User < ApplicationRecord
authenticates_with_sorcery!
has_many :authentications, dependent: :destroy
has_many :forms, dependent: :destroy
def deactivate!(_reason = nil)
# currently we only use deactivate if we get an authentication exception appending data to a spreadsheet
authentications.last&.update(expires_at: Time.current)
end
def active?
authentications.any? { |a| !a.expired? }
end
def google_authorization
authentications.for(:google).last.google_authorization
end
end