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