mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
When banning a user, a reason can be provided. The user will see this reason when trying to log in. Also log bans and unbans in the staff action logs.
This commit is contained in:
@@ -57,6 +57,23 @@ class StaffActionLogger
|
||||
}))
|
||||
end
|
||||
|
||||
def log_user_ban(user, reason, opts={})
|
||||
raise Discourse::InvalidParameters.new('user is nil') unless user
|
||||
UserHistory.create( params(opts).merge({
|
||||
action: UserHistory.actions[:ban_user],
|
||||
target_user_id: user.id,
|
||||
details: reason
|
||||
}))
|
||||
end
|
||||
|
||||
def log_user_unban(user, opts={})
|
||||
raise Discourse::InvalidParameters.new('user is nil') unless user
|
||||
UserHistory.create( params(opts).merge({
|
||||
action: UserHistory.actions[:unban_user],
|
||||
target_user_id: user.id
|
||||
}))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def params(opts)
|
||||
|
||||
Reference in New Issue
Block a user