2013-03-25 20:04:28 -05:00
|
|
|
class Admin::ApiController < Admin::AdminController
|
2013-10-22 14:53:08 -05:00
|
|
|
|
2013-03-25 20:04:28 -05:00
|
|
|
def index
|
2013-10-23 21:40:18 -05:00
|
|
|
render_serialized(ApiKey.all.to_a, ApiKeySerializer)
|
2013-10-22 14:53:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def regenerate_key
|
|
|
|
api_key = ApiKey.where(id: params[:id]).first
|
|
|
|
raise Discourse::NotFound.new if api_key.blank?
|
|
|
|
|
|
|
|
api_key.regenerate!(current_user)
|
|
|
|
render_serialized(api_key, ApiKeySerializer)
|
2013-03-25 20:04:28 -05:00
|
|
|
end
|
|
|
|
|
2013-10-22 14:53:08 -05:00
|
|
|
def revoke_key
|
|
|
|
api_key = ApiKey.where(id: params[:id]).first
|
|
|
|
raise Discourse::NotFound.new if api_key.blank?
|
|
|
|
|
|
|
|
api_key.destroy
|
|
|
|
render nothing: true
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_master_key
|
|
|
|
api_key = ApiKey.create_master_key
|
|
|
|
render_serialized(api_key, ApiKeySerializer)
|
2013-03-25 20:04:28 -05:00
|
|
|
end
|
2013-10-22 14:53:08 -05:00
|
|
|
|
2013-03-25 20:04:28 -05:00
|
|
|
end
|