FIX: invite approval `StaffActionLogger` bug (#7151)

* FIX: invite approval `StaffActionLogger` bug
This commit is contained in:
Tarek Khalil 2019-03-12 13:32:25 +00:00 committed by GitHub
parent 6d0528687d
commit 4a00772c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 10 deletions

View File

@ -133,7 +133,7 @@ InviteRedeemer = Struct.new(:invite, :username, :name, :password, :user_custom_f
def approve_account_if_needed
if get_existing_user
invited_user.approve(invite.invited_by_id, false)
invited_user.approve(invite.invited_by, false)
end
end

View File

@ -405,23 +405,17 @@ class User < ActiveRecord::Base
end
# Approve this user
def approve(approved_by, send_mail = true)
def approve(approver, send_mail = true)
self.approved = true
if approved_by.is_a?(Integer)
self.approved_by_id = approved_by
else
self.approved_by = approved_by
end
self.approved_at = Time.zone.now
self.approved_by = approver
if result = save
send_approval_email if send_mail
DiscourseEvent.trigger(:user_approved, self)
end
StaffActionLogger.new(approved_by).log_user_approve(self)
StaffActionLogger.new(approver).log_user_approve(self)
result
end