Skip to content

Commit 55108e6

Browse files
ysksnhiyuki2578
authored andcommitted
Move #set_user to Admin::BaseController (mastodon#9470)
* Move #set_user to Admin::BaseController * Rename Admin::TwoFactorAuthenticationsController from `#set_user` to `#set_target_user` .
1 parent cd00da1 commit 55108e6

5 files changed

Lines changed: 6 additions & 18 deletions

File tree

app/controllers/admin/base_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ class BaseController < ApplicationController
1515
def set_body_classes
1616
@body_classes = 'admin'
1717
end
18+
19+
def set_user
20+
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
21+
end
1822
end
1923
end

app/controllers/admin/confirmations_controller.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ def resend
2525

2626
private
2727

28-
def set_user
29-
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
30-
end
31-
3228
def check_confirmation
3329
if @user.confirmed?
3430
flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed')

app/controllers/admin/resets_controller.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,5 @@ def create
1010
log_action :reset_password, @user
1111
redirect_to admin_accounts_path
1212
end
13-
14-
private
15-
16-
def set_user
17-
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
18-
end
1913
end
2014
end

app/controllers/admin/roles_controller.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,5 @@ def demote
1717
log_action :demote, @user
1818
redirect_to admin_account_path(@user.account_id)
1919
end
20-
21-
private
22-
23-
def set_user
24-
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
25-
end
2620
end
2721
end

app/controllers/admin/two_factor_authentications_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Admin
44
class TwoFactorAuthenticationsController < BaseController
5-
before_action :set_user
5+
before_action :set_target_user
66

77
def destroy
88
authorize @user, :disable_2fa?
@@ -13,7 +13,7 @@ def destroy
1313

1414
private
1515

16-
def set_user
16+
def set_target_user
1717
@user = User.find(params[:user_id])
1818
end
1919
end

0 commit comments

Comments
 (0)