2013-03-25 21:04:28 -04:00
|
|
|
class Admin::ApiController < Admin::AdminController
|
2013-10-22 15:53:08 -04:00
|
|
|
|
2013-03-25 21:04:28 -04:00
|
|
|
def index
|
2014-11-19 23:38:20 -05:00
|
|
|
render_serialized(ApiKey.where(hidden: false).to_a, ApiKeySerializer)
|
2013-10-22 15:53:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def regenerate_key
|
2014-05-06 09:41:59 -04:00
|
|
|
api_key = ApiKey.find_by(id: params[:id])
|
2015-05-06 21:00:51 -04:00
|
|
|
raise Discourse::NotFound if api_key.blank?
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
api_key.regenerate!(current_user)
|
|
|
|
render_serialized(api_key, ApiKeySerializer)
|
2013-03-25 21:04:28 -04:00
|
|
|
end
|
|
|
|
|
2013-10-22 15:53:08 -04:00
|
|
|
def revoke_key
|
2014-05-06 09:41:59 -04:00
|
|
|
api_key = ApiKey.find_by(id: params[:id])
|
2015-05-06 21:00:51 -04:00
|
|
|
raise Discourse::NotFound if api_key.blank?
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
api_key.destroy
|
2017-08-31 00:06:56 -04:00
|
|
|
render body: nil
|
2013-10-22 15:53:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_master_key
|
|
|
|
api_key = ApiKey.create_master_key
|
|
|
|
render_serialized(api_key, ApiKeySerializer)
|
2013-03-25 21:04:28 -04:00
|
|
|
end
|
2013-10-22 15:53:08 -04:00
|
|
|
|
2013-03-25 21:04:28 -04:00
|
|
|
end
|