gitlab-org--gitlab-foss/app/controllers/profiles/gpg_keys_controller.rb

48 lines
999 B
Ruby
Raw Normal View History

class Profiles::GpgKeysController < Profiles::ApplicationController
2017-07-25 10:24:22 -04:00
before_action :set_gpg_key, only: [:destroy, :revoke]
def index
2017-09-27 21:45:08 -04:00
@gpg_keys = current_user.gpg_keys.with_subkeys
@gpg_key = GpgKey.new
end
def create
2017-09-15 11:35:24 -04:00
@gpg_key = GpgKeys::CreateService.new(current_user, gpg_key_params).execute
2017-09-15 11:35:24 -04:00
if @gpg_key.persisted?
redirect_to profile_gpg_keys_path
else
@gpg_keys = current_user.gpg_keys.select(&:persisted?)
render :index
end
end
def destroy
2017-07-25 10:24:22 -04:00
@gpg_key.destroy
respond_to do |format|
format.html { redirect_to profile_gpg_keys_url, status: 302 }
format.js { head :ok }
end
end
def revoke
2017-07-25 10:24:22 -04:00
@gpg_key.revoke
respond_to do |format|
format.html { redirect_to profile_gpg_keys_url, status: 302 }
format.js { head :ok }
end
end
private
def gpg_key_params
params.require(:gpg_key).permit(:key)
end
2017-07-25 10:24:22 -04:00
def set_gpg_key
@gpg_key = current_user.gpg_keys.find(params[:id])
end
end