summaryrefslogtreecommitdiff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-03-01 16:59:03 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-03-06 19:18:26 +0000
commit005749a616c19b90d6ec0415df9ae5e35151e33c (patch)
treef1618dbe99a4ed60980dc94f831864f9e701c589 /app/controllers/admin
parent2b474dc2b226460782413e634792cf83e791173b (diff)
downloadgitlab-ce-005749a616c19b90d6ec0415df9ae5e35151e33c.tar.gz
apply codestyle and implementation changes to the respective feature codepersonal_access_token_api_and_impersonation_token
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/impersonation_tokens_controller.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb
index 448f2c881a1..d26004539b5 100644
--- a/app/controllers/admin/impersonation_tokens_controller.rb
+++ b/app/controllers/admin/impersonation_tokens_controller.rb
@@ -1,12 +1,12 @@
class Admin::ImpersonationTokensController < Admin::ApplicationController
- before_action :user, :finder
+ before_action :user
def index
set_index_vars
end
def create
- @impersonation_token = finder.execute.build(impersonation_token_params)
+ @impersonation_token = finder.build(impersonation_token_params)
if @impersonation_token.save
flash[:impersonation_token] = @impersonation_token.token
@@ -18,7 +18,7 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
end
def revoke
- @impersonation_token = finder.execute(id: params[:id])
+ @impersonation_token = finder.find(params[:id])
if @impersonation_token.revoke!
flash[:notice] = "Revoked impersonation token #{@impersonation_token.name}!"
@@ -35,8 +35,8 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
@user ||= User.find_by!(username: params[:user_id])
end
- def finder
- @finder ||= PersonalAccessTokensFinder.new(user: user, impersonation: true)
+ def finder(options = {})
+ PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
end
def impersonation_token_params
@@ -44,12 +44,10 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
end
def set_index_vars
- finder.params[:state] = 'active'
- @impersonation_token ||= finder.execute.build
@scopes = Gitlab::Auth::SCOPES
- finder.params[:order] = :expires_at
- @active_impersonation_tokens = finder.execute
- finder.params[:state] = 'inactive'
- @inactive_impersonation_tokens = finder.execute
+
+ @impersonation_token ||= finder.build
+ @inactive_impersonation_tokens = finder(state: 'inactive').execute
+ @active_impersonation_tokens = finder(state: 'active').execute.order(:expires_at)
end
end