Merge pull request 'Add lndhub admin panel, quick stats for admin pages' (#80) from feature/admin_stats into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #80
Reviewed-by: bumi <bumi@noreply.kosmos.org>
This commit was merged in pull request #80.
This commit is contained in:
2023-02-23 07:43:15 +00:00
45 changed files with 604 additions and 129 deletions

View File

@@ -5,11 +5,28 @@ class User < ApplicationRecord
has_many :invitations, dependent: :destroy
has_many :donations, dependent: :nullify
has_one :lndhub_user, class_name: "LndhubUser", inverse_of: "user",
primary_key: "ln_account", foreign_key: "login"
has_many :accounts, through: :lndhub_user
validates_uniqueness_of :cn
validates_length_of :cn, :minimum => 3
validates_format_of :cn, with: /\A([a-z0-9\-])*\z/,
if: Proc.new{ |u| u.cn.present? },
message: "is invalid. Please use only letters, numbers and -"
validates_format_of :cn, without: /\A-/,
if: Proc.new{ |u| u.cn.present? },
message: "is invalid. Usernames need to start with a letter."
validates_format_of :cn, without: /\A(#{Setting.reserved_usernames.join('|')})\z/i,
message: "has already been taken"
validates_uniqueness_of :email
validates :email, email: true
scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :pending, -> { where(confirmed_at: nil) }
lockbox_encrypts :ln_login
lockbox_encrypts :ln_password