feat(ntfy): add ntfy fields to admin_users and ntfy_configured? method
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
class AdminUser < ApplicationRecord
|
||||
has_secure_password
|
||||
|
||||
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validates :email, presence: true, uniqueness: { case_sensitive: false }, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validates :name, presence: true
|
||||
validates :password, length: { minimum: 8 }, if: -> { password.present? }
|
||||
|
||||
before_validation :normalize_email
|
||||
|
||||
def update_last_login!
|
||||
update!(last_login_at: Time.current)
|
||||
end
|
||||
|
||||
def ntfy_configured?
|
||||
ntfy_enabled? && ntfy_topic.present? && ntfy_token.present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def normalize_email
|
||||
self.email = email&.downcase&.strip
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user