mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 21:27:16 -05: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:
@@ -42,7 +42,7 @@ class Admin::UsersController < Admin::AdminController
|
||||
@user.banned_till = params[:duration].to_i.days.from_now
|
||||
@user.banned_at = DateTime.now
|
||||
@user.save!
|
||||
# TODO logging
|
||||
StaffActionLogger.new(current_user).log_user_ban(@user, params[:reason])
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ class Admin::UsersController < Admin::AdminController
|
||||
@user.banned_till = nil
|
||||
@user.banned_at = nil
|
||||
@user.save!
|
||||
# TODO logging
|
||||
StaffActionLogger.new(current_user).log_user_unban(@user)
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@ class SessionController < ApplicationController
|
||||
if @user.confirm_password?(password)
|
||||
|
||||
if @user.is_banned?
|
||||
render json: { error: I18n.t("login.banned", {date: I18n.l(@user.banned_till, format: :date_only)}) }
|
||||
if reason = @user.ban_reason
|
||||
render json: { error: I18n.t("login.banned_with_reason", {date: I18n.l(@user.banned_till, format: :date_only), reason: reason}) }
|
||||
else
|
||||
render json: { error: I18n.t("login.banned", {date: I18n.l(@user.banned_till, format: :date_only)}) }
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user