mirror of
https://github.com/discourse/discourse.git
synced 2025-06-23 03:51:43 +08:00

**Note:** Do not merge before the backfill (#31606) is merged. ### What is this change? We're now storing the selected API key scope mode in the back-end, and can display it in the API key list. **Screenshot:** <img width="551" alt="Screenshot 2025-03-04 at 7 27 42 PM" src="https://github.com/user-attachments/assets/9f234242-cfaa-4a2c-93e9-740770bd9944" />
27 lines
689 B
Ruby
27 lines
689 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ApiKeySerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:key,
|
|
:truncated_key,
|
|
:description,
|
|
:scope_mode,
|
|
:last_used_at,
|
|
:created_at,
|
|
:updated_at,
|
|
:revoked_at
|
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
|
has_one :created_by, serializer: BasicUserSerializer, embed: :objects
|
|
has_many :api_key_scopes, serializer: ApiKeyScopeSerializer, embed: :objects
|
|
|
|
def include_user_id?
|
|
!object.user_id.nil?
|
|
end
|
|
|
|
def include_key?
|
|
# Only available when first created. Not stored in db
|
|
object.key_available?
|
|
end
|
|
end
|