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