discourse/app/controllers/admin/api_controller.rb

31 lines
670 B
Ruby
Raw Normal View History

2019-05-02 14:57:12 +08:00
# frozen_string_literal: true
2013-03-26 09:04:28 +08:00
class Admin::ApiController < Admin::AdminController
2013-10-23 03:53:08 +08:00
2013-03-26 09:04:28 +08:00
def index
render_serialized(ApiKey.where(hidden: false).to_a, ApiKeySerializer)
2013-10-23 03:53:08 +08:00
end
def regenerate_key
api_key = ApiKey.find_by(id: params[:id])
2015-05-07 09:00:51 +08:00
raise Discourse::NotFound if api_key.blank?
2013-10-23 03:53:08 +08:00
api_key.regenerate!(current_user)
render_serialized(api_key, ApiKeySerializer)
2013-03-26 09:04:28 +08:00
end
2013-10-23 03:53:08 +08:00
def revoke_key
api_key = ApiKey.find_by(id: params[:id])
2015-05-07 09:00:51 +08:00
raise Discourse::NotFound if api_key.blank?
2013-10-23 03:53:08 +08:00
api_key.destroy
render body: nil
2013-10-23 03:53:08 +08:00
end
def create_master_key
api_key = ApiKey.create_master_key
render_serialized(api_key, ApiKeySerializer)
2013-03-26 09:04:28 +08:00
end
2013-10-23 03:53:08 +08:00
2013-03-26 09:04:28 +08:00
end