2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-12-30 09:15:11 +00:00
|
|
|
class Admin::KeysController < Admin::ApplicationController
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :user, only: [:show, :destroy]
|
2014-12-30 09:15:11 +00:00
|
|
|
|
2020-10-05 21:08:47 +00:00
|
|
|
feature_category :authentication_and_authorization
|
|
|
|
|
2014-12-30 09:15:11 +00:00
|
|
|
def show
|
|
|
|
@key = user.keys.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
2016-03-16 01:16:25 +00:00
|
|
|
format.js { head :ok }
|
2014-12-30 09:15:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
key = user.keys.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if key.destroy
|
2019-11-17 12:06:19 +00:00
|
|
|
format.html { redirect_to keys_admin_user_path(user), status: :found, notice: _('User key was successfully removed.') }
|
2014-12-30 09:15:11 +00:00
|
|
|
else
|
2019-11-17 12:06:19 +00:00
|
|
|
format.html { redirect_to keys_admin_user_path(user), status: :found, alert: _('Failed to remove user key.') }
|
2014-12-30 09:15:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2014-12-30 09:15:11 +00:00
|
|
|
def user
|
|
|
|
@user ||= User.find_by!(username: params[:user_id])
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2014-12-30 09:15:11 +00:00
|
|
|
|
|
|
|
def key_params
|
|
|
|
params.require(:user_id, :id)
|
|
|
|
end
|
|
|
|
end
|