diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2014-12-30 10:15:11 +0100 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2014-12-30 10:15:11 +0100 |
commit | 82829ed49e11a173275633cad63978e4ee07e927 (patch) | |
tree | 1ed868a3ddffb03acf86da5207750521e8156930 /app/controllers | |
parent | c1e57b47b81db4b3959b0ce63d7f65cb6cdf6f57 (diff) | |
download | gitlab-ce-82829ed49e11a173275633cad63978e4ee07e927.tar.gz |
Move user key manipulation in admin section to a separate controller.
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin/keys_controller.rb | 34 | ||||
-rw-r--r-- | app/controllers/admin/users_controller.rb | 21 |
2 files changed, 34 insertions, 21 deletions
diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb new file mode 100644 index 00000000000..21111bb44f5 --- /dev/null +++ b/app/controllers/admin/keys_controller.rb @@ -0,0 +1,34 @@ +class Admin::KeysController < Admin::ApplicationController + before_filter :user, only: [:show, :destroy] + + def show + @key = user.keys.find(params[:id]) + + respond_to do |format| + format.html + format.js { render nothing: true } + end + end + + def destroy + key = user.keys.find(params[:id]) + + respond_to do |format| + if key.destroy + format.html { redirect_to [:admin, user], notice: 'User key was successfully removed.' } + else + format.html { redirect_to [:admin, user], alert: 'Failed to remove user key.' } + end + end + end + + protected + + def user + @user ||= User.find_by!(username: params[:user_id]) + end + + def key_params + params.require(:user_id, :id) + end +end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b11a0b04687..86c671ed756 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -108,27 +108,6 @@ class Admin::UsersController < Admin::ApplicationController end end - def show_key - @key = user.keys.find(params[:key_id]) - - respond_to do |format| - format.html { render 'key' } - format.js { render nothing: true } - end - end - - def remove_key - key = user.keys.find(params[:key_id]) - - respond_to do |format| - if key.destroy - format.html { redirect_to [:admin, user], notice: 'User key was successfully removed.' } - else - format.html { redirect_to [:admin, user], alert: 'Failed to remove user key.' } - end - end - end - protected def user |