mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:52:45 +08:00
DEV: Remove initiating_user
keyword arg from EmailUpdater
.
The guardian contains the acting user.
This commit is contained in:
parent
50d4ad562e
commit
2188ccccd5
|
@ -35,7 +35,7 @@ class UsersEmailController < ApplicationController
|
|||
RateLimiter.new(user, "change-email-hr-#{request.remote_ip}", 6, 1.hour).performed!
|
||||
RateLimiter.new(user, "change-email-min-#{request.remote_ip}", 3, 1.minute).performed!
|
||||
|
||||
updater = EmailUpdater.new(guardian: guardian, user: user, initiating_user: current_user)
|
||||
updater = EmailUpdater.new(guardian: guardian, user: user)
|
||||
updater.change_to(params[:email])
|
||||
|
||||
if updater.errors.present?
|
||||
|
|
|
@ -5,10 +5,9 @@ class EmailUpdater
|
|||
|
||||
attr_reader :user
|
||||
|
||||
def initialize(guardian: nil, user: nil, initiating_user: nil)
|
||||
def initialize(guardian: nil, user: nil)
|
||||
@guardian = guardian
|
||||
@user = user
|
||||
@initiating_user = initiating_user
|
||||
end
|
||||
|
||||
def self.human_attribute_name(name, options = {})
|
||||
|
@ -135,7 +134,7 @@ class EmailUpdater
|
|||
end
|
||||
|
||||
def initiating_admin_changing_another_user_email?
|
||||
@initiating_user&.admin? && @initiating_user != @user
|
||||
@guardian.is_admin? && @guardian.user != @user
|
||||
end
|
||||
|
||||
def auto_confirm_and_send_password_reset(email_token)
|
||||
|
|
|
@ -19,7 +19,7 @@ describe EmailUpdater do
|
|||
|
||||
context "when an admin is changing the email of another user" do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
let(:updater) { EmailUpdater.new(guardian: user.guardian, user: user, initiating_user: admin) }
|
||||
let(:updater) { EmailUpdater.new(guardian: admin.guardian, user: user) }
|
||||
|
||||
def expect_old_email_job
|
||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(to_address: old_email, type: :notify_old_email, user_id: user.id))
|
||||
|
|
Loading…
Reference in New Issue
Block a user