Comments
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Râu Cao 2023-09-06 12:16:00 +02:00
parent 9e5aeaf572
commit def44618ef
Signed by: raucao
GPG Key ID: 15E65F399D084BA9

View File

@ -11,7 +11,10 @@ class User < ApplicationRecord
has_one_attached :avatar
#
# Relations
#
has_many :invitations, dependent: :destroy
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
has_one :inviter, through: :invitation, source: :user
@ -26,6 +29,10 @@ class User < ApplicationRecord
has_many :remote_storage_authorizations
#
# Validations
#
validates_uniqueness_of :cn, scope: :ou
validates_length_of :cn, minimum: 3
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
validate :acceptable_avatar
#
# Scopes
#
scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :pending, -> { where(confirmed_at: nil) }
scope :all_except, -> (user) { where.not(id: user) }
#
# Encrypted database columns
#
has_encrypted :ln_login, :ln_password
# Include default devise modules. Others available are: