Files
fizzy/app/models/user.rb
T
Jorge Manrubia b08326ccbe Merge branch 'main' into plain-text-mentions
* main: (48 commits)
  Improve layout and truncation
  This is annoying
  Fix summary
  Remove index columns
  Same treatment for the events index
  New menu filters and navigates
  Don't test for _Added by_ events
  Indention
  @collection is always available when card scoped
  Style
  Remove check for _Added by..._ line
  The placeholder attribute is on the `house-md` element
  Duh, no before destroy commit, but this is still not right!
  No long transactions!
  Don't display published event in threads
  But feels more essentially part of the User, so list first
  Not related to the other two
  Missing controller
  Style
  Errant `bubbles` => `cards` replacement
  ...

# Conflicts:
#	app/models/card.rb
#	app/models/user.rb
#	db/schema.rb
#	db/schema_cache.yml
2025-04-23 17:24:01 +02:00

31 lines
870 B
Ruby

class User < ApplicationRecord
include Accessor, Assignee, Named, Role, Transferable
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
normalizes :email_address, with: ->(value) { value.strip.downcase }
def deactivate
sessions.delete_all
accesses.destroy_all
update! active: false, email_address: deactived_email_address
end
private
def deactived_email_address
email_address.sub(/@/, "-deactivated-#{SecureRandom.uuid}@")
end
end