mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:41:45 +08:00
FEATURE: Log user approvals. (#7121)
This commit is contained in:
parent
da941840d4
commit
191e31dccf
|
@ -421,6 +421,8 @@ class User < ActiveRecord::Base
|
|||
DiscourseEvent.trigger(:user_approved, self)
|
||||
end
|
||||
|
||||
StaffActionLogger.new(approved_by).log_user_approve(self)
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ class UserHistory < ActiveRecord::Base
|
|||
merge_user: 65,
|
||||
entity_export: 66,
|
||||
change_password: 67,
|
||||
topic_timestamps_changed: 68
|
||||
topic_timestamps_changed: 68,
|
||||
approve_user: 69
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -147,7 +148,8 @@ class UserHistory < ActiveRecord::Base
|
|||
:merge_user,
|
||||
:entity_export,
|
||||
:change_name,
|
||||
:topic_timestamps_changed
|
||||
:topic_timestamps_changed,
|
||||
:approve_user
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -503,6 +503,13 @@ class StaffActionLogger
|
|||
))
|
||||
end
|
||||
|
||||
def log_user_approve(user, opts = {})
|
||||
UserHistory.create!(params(opts).merge(
|
||||
action: UserHistory.actions[:approve_user],
|
||||
target_user_id: user.id
|
||||
))
|
||||
end
|
||||
|
||||
def log_user_deactivate(user, reason, opts = {})
|
||||
raise Discourse::InvalidParameters.new(:user) unless user
|
||||
UserHistory.create!(params(opts).merge(
|
||||
|
|
|
@ -3689,6 +3689,7 @@ en:
|
|||
entity_export: "export entity"
|
||||
change_name: "change name"
|
||||
topic_timestamps_changed: "topic timestamps changed"
|
||||
approve_user: "approved user"
|
||||
screened_emails:
|
||||
title: "Screened Emails"
|
||||
description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."
|
||||
|
|
|
@ -71,6 +71,7 @@ RSpec.describe Admin::UsersController do
|
|||
expect(response.status).to eq(200)
|
||||
evil_trout.reload
|
||||
expect(evil_trout.approved).to eq(true)
|
||||
expect(UserHistory.where(action: UserHistory.actions[:approve_user], target_user_id: evil_trout.id).count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user