Class: Railspress::Admin::ApiKeysController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Railspress::Admin::ApiKeysController
- Defined in:
- app/controllers/railspress/admin/api_keys_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/railspress/admin/api_keys_controller.rb', line 20 def create @api_key, @plain_token = ApiKey.issue!( name: api_key_params[:name], actor: current_api_actor, owner: current_api_actor, expires_at: parsed_expires_at ) set_api_key_instructions render :reveal, status: :created rescue ActiveRecord::RecordInvalid => e @api_key = e.record render :new, status: :unprocessable_content end |
#index ⇒ Object
11 12 13 14 |
# File 'app/controllers/railspress/admin/api_keys_controller.rb', line 11 def index @api_keys = ApiKey.recent @agent_bootstrap_keys = AgentBootstrapKey.recent end |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/railspress/admin/api_keys_controller.rb', line 16 def new @api_key = ApiKey.new end |
#revoke ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/controllers/railspress/admin/api_keys_controller.rb', line 44 def revoke @api_key.revoke!( actor: current_api_actor, reason: params[:reason].presence || "revoked" ) redirect_to admin_api_keys_path, notice: "API key revoked." end |
#rotate ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/railspress/admin/api_keys_controller.rb', line 35 def rotate @api_key, @plain_token = @api_key.rotate!( actor: current_api_actor, expires_at: @api_key.expires_at ) set_api_key_instructions render :reveal, status: :created end |