Sha256: 914812bad807d2784c7207dc71964e36b19aeaf60c069f5b8d2dc2041314aad3

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

class PublicKeysController < ApplicationController
  load_and_authorize_resource

  # GET /public_keys
  # GET /public_keys.json
  def index
    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @public_keys }
    end
  end

  # GET /public_keys/1
  # GET /public_keys/1.json
  def show
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @public_key }
    end
  end

  # GET /public_keys/new
  # GET /public_keys/new.json
  def new
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @public_key }
    end
  end

  # POST /public_keys
  # POST /public_keys.json
  def create
    @public_key.user = current_user
    respond_to do |format|
      if @public_key.save
        # PublicKey.regenerate_authorized_keys
        GitWit.add_authorized_key(current_user.username, @public_key.raw_content)

        format.html { redirect_to @public_key, notice: 'Public key was successfully created.' }
        format.json { render json: @public_key, status: :created, location: @public_key }
      else
        format.html { render action: "new" }
        format.json { render json: @public_key.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /public_keys/1
  # DELETE /public_keys/1.json
  def destroy
    @public_key.destroy
    # PublicKey.regenerate_authorized_keys
    GitWit.remove_authorized_key(@public_key.raw_content)

    respond_to do |format|
      format.html { redirect_to public_keys_url }
      format.json { head :no_content }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git_wit-0.0.6 test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.6.pre test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.5 test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.4.pre2 test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.4.pre test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.3 test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.2 test/dummy/app/controllers/public_keys_controller.rb
git_wit-0.0.1 test/dummy/app/controllers/public_keys_controller.rb