* 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.
27 lines
753 B
Ruby
27 lines
753 B
Ruby
class ApiKeysController < ApplicationController
|
|
respond_to :html, :json, :xml
|
|
|
|
def create
|
|
@api_key = authorize ApiKey.new(user: CurrentUser.user)
|
|
@api_key.save
|
|
respond_with(@api_key, location: user_api_keys_path(CurrentUser.user.id))
|
|
end
|
|
|
|
def index
|
|
params[:search][:user_id] = params[:user_id] if params[:user_id].present?
|
|
@api_keys = authorize ApiKey.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
|
respond_with(@api_keys)
|
|
end
|
|
|
|
def show
|
|
@api_key = authorize ApiKey.find(params[:id])
|
|
respond_with(@api_key)
|
|
end
|
|
|
|
def destroy
|
|
@api_key = authorize ApiKey.find(params[:id])
|
|
@api_key.destroy
|
|
respond_with(@api_key, location: user_api_keys_path(CurrentUser.user.id))
|
|
end
|
|
end
|