Files
danbooru/app/models/api_key.rb
evazion 37061f95a6 api keys: rework API key UI.
* Add an explanation of what an API key is and how to use it.
* Make it possible for the site owner to view all API keys.
* Remove the requirement to re-enter your password before you can view
  your API key (to be reworked).
* Move the API key controller from maintenance/user/api_keys_controller.rb
  to a top level controller.
2021-02-14 04:09:47 -06:00

21 lines
406 B
Ruby

class ApiKey < ApplicationRecord
belongs_to :user
validates_uniqueness_of :user_id
validates_uniqueness_of :key
has_secure_token :key
def self.visible(user)
if user.is_owner?
all
else
where(user: user)
end
end
def self.search(params)
q = search_attributes(params, :id, :created_at, :updated_at, :key, :user)
q = q.apply_default_order(params)
q
end
end