mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:09:35 +08:00
1574485443
This refactoring was automated using the command: bundle exec "ruby refactorings/where_dot_first_to_find_by/app.rb"
29 lines
634 B
Ruby
29 lines
634 B
Ruby
class Admin::ApiController < Admin::AdminController
|
|
|
|
def index
|
|
render_serialized(ApiKey.all.to_a, ApiKeySerializer)
|
|
end
|
|
|
|
def regenerate_key
|
|
api_key = ApiKey.find_by(id: params[:id])
|
|
raise Discourse::NotFound.new if api_key.blank?
|
|
|
|
api_key.regenerate!(current_user)
|
|
render_serialized(api_key, ApiKeySerializer)
|
|
end
|
|
|
|
def revoke_key
|
|
api_key = ApiKey.find_by(id: params[:id])
|
|
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)
|
|
end
|
|
|
|
end
|