keys_controller.rb 634 Bytes
Newer Older
1
class Profiles::KeysController < ApplicationController
gitlabhq's avatar
gitlabhq committed
2
  layout "profile"
gitlabhq's avatar
gitlabhq committed
3 4

  def index
skv's avatar
skv committed
5
    @keys = current_user.keys.order('id DESC')
gitlabhq's avatar
gitlabhq committed
6 7
  end

8 9 10 11
  def show
    @key = current_user.keys.find(params[:id])
  end

gitlabhq's avatar
gitlabhq committed
12 13 14 15 16 17 18
  def new
    @key = current_user.keys.new
  end

  def create
    @key = current_user.keys.new(params[:key])

19 20 21 22 23
    if @key.save
      redirect_to profile_key_path(@key)
    else
      render 'new'
    end
gitlabhq's avatar
gitlabhq committed
24 25 26 27 28 29 30
  end

  def destroy
    @key = current_user.keys.find(params[:id])
    @key.destroy

    respond_to do |format|
31
      format.html { redirect_to profile_keys_url }
32
      format.js { render nothing: true }
gitlabhq's avatar
gitlabhq committed
33 34 35
    end
  end
end