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:
Neil Lalonde
2013-11-01 10:47:26 -04:00
parent 52b0c1c45f
commit 92a0729937
17 changed files with 180 additions and 26 deletions
+2 -2
View File
@@ -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
+5 -1
View File
@@ -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