This commit is contained in:
parent
9e5aeaf572
commit
def44618ef
@ -11,7 +11,10 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
has_one_attached :avatar
|
has_one_attached :avatar
|
||||||
|
|
||||||
|
#
|
||||||
# Relations
|
# Relations
|
||||||
|
#
|
||||||
|
|
||||||
has_many :invitations, dependent: :destroy
|
has_many :invitations, dependent: :destroy
|
||||||
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
|
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
|
||||||
has_one :inviter, through: :invitation, source: :user
|
has_one :inviter, through: :invitation, source: :user
|
||||||
@ -26,6 +29,10 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
has_many :remote_storage_authorizations
|
has_many :remote_storage_authorizations
|
||||||
|
|
||||||
|
#
|
||||||
|
# Validations
|
||||||
|
#
|
||||||
|
|
||||||
validates_uniqueness_of :cn, scope: :ou
|
validates_uniqueness_of :cn, scope: :ou
|
||||||
validates_length_of :cn, minimum: 3
|
validates_length_of :cn, minimum: 3
|
||||||
validates_format_of :cn, with: /\A([a-z0-9\-])*\z/,
|
validates_format_of :cn, with: /\A([a-z0-9\-])*\z/,
|
||||||
@ -47,10 +54,19 @@ class User < ApplicationRecord
|
|||||||
validates_uniqueness_of :nostr_pubkey, allow_blank: true
|
validates_uniqueness_of :nostr_pubkey, allow_blank: true
|
||||||
|
|
||||||
validate :acceptable_avatar
|
validate :acceptable_avatar
|
||||||
|
|
||||||
|
#
|
||||||
|
# Scopes
|
||||||
|
#
|
||||||
|
|
||||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||||
scope :pending, -> { where(confirmed_at: nil) }
|
scope :pending, -> { where(confirmed_at: nil) }
|
||||||
scope :all_except, -> (user) { where.not(id: user) }
|
scope :all_except, -> (user) { where.not(id: user) }
|
||||||
|
|
||||||
|
#
|
||||||
|
# Encrypted database columns
|
||||||
|
#
|
||||||
|
|
||||||
has_encrypted :ln_login, :ln_password
|
has_encrypted :ln_login, :ln_password
|
||||||
|
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user