dfb6198e94
* main: (50 commits) Regenerate fixtures Let summaries know about collections Regenerate fixtures More tweaks Regenerate fixtures after tweaking prompt Fix model selection (I had broken it!) Some prompt refinements Some of us have basecamp.com email addresses Update nokogiri and thor to addres CVEs Fix tests Format Move model options to helper Tidy up the admin tool for prompts Extract methods Format Default to the current summary Make models selectable Add an animated effect for the generating state Remove debug Wrap them both in the container so the generating state looks right ...
37 lines
1.2 KiB
Ruby
37 lines
1.2 KiB
Ruby
class User < ApplicationRecord
|
|
include Accessor, Attachable, Assignee, Mentionable, Named, Role, Searcher,
|
|
SignalUser, Staff, Transferable
|
|
include Timelined # Depends on Accessor
|
|
|
|
has_one_attached :avatar
|
|
|
|
has_many :sessions, dependent: :destroy
|
|
has_secure_password validations: false
|
|
|
|
has_many :comments, inverse_of: :creator, dependent: :destroy
|
|
|
|
has_many :notifications, dependent: :destroy
|
|
|
|
has_many :filters, foreign_key: :creator_id, inverse_of: :creator, dependent: :destroy
|
|
has_many :closures, dependent: :nullify
|
|
has_many :pins, dependent: :destroy
|
|
has_many :pinned_cards, through: :pins, source: :card
|
|
has_many :commands, dependent: :destroy
|
|
has_many :push_subscriptions, class_name: "Push::Subscription", dependent: :delete_all
|
|
has_many :period_activity_summaries, dependent: :destroy
|
|
|
|
normalizes :email_address, with: ->(value) { value.strip.downcase }
|
|
|
|
def deactivate
|
|
sessions.delete_all
|
|
accesses.destroy_all
|
|
SignalId::Database.on_master { signal_user&.destroy }
|
|
update! active: false, email_address: deactived_email_address
|
|
end
|
|
|
|
private
|
|
def deactived_email_address
|
|
email_address.sub(/@/, "-deactivated-#{SecureRandom.uuid}@")
|
|
end
|
|
end
|