add max length to public api keys

This commit is contained in:
24c02 2025-07-01 12:32:44 -04:00
parent 2f7d25f9de
commit c98a91d1f0

View file

@ -25,6 +25,7 @@ class Public::APIKey < ApplicationRecord
belongs_to :public_user, class_name: "Public::User"
validates :token, presence: true, uniqueness: true
validates :name, length: { maximum: 100 }
scope :not_revoked, -> { where(revoked_at: nil).or(where(revoked_at: Time.now..)) }
scope :accessible, -> { not_revoked }