diff options
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index 78b0a38bcaa..35fc42a935f 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -32,6 +32,12 @@ class Key < ApplicationRecord delegate :name, :email, to: :user, prefix: true + enum usage_type: { + auth_and_signing: 0, + auth: 1, + signing: 2 + } + after_commit :add_to_authorized_keys, on: :create after_create :post_create_hook after_create :refresh_user_cache @@ -45,6 +51,8 @@ class Key < ApplicationRecord scope :preload_users, -> { preload(:user) } scope :for_user, -> (user) { where(user: user) } scope :order_last_used_at_desc, -> { reorder(arel_table[:last_used_at].desc.nulls_last) } + scope :auth, -> { where(usage_type: [:auth, :auth_and_signing]) } + scope :signing, -> { where(usage_type: [:signing, :auth_and_signing]) } # Date is set specifically in this scope to improve query time. scope :expired_today_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') = CURRENT_DATE AND expiry_notification_delivered_at IS NULL"]) } |