Disclose permanent ban duration in login notice

This commit is contained in:
Andreas Nedbal 2023-12-11 01:20:02 +01:00 committed by Andreas Nedbal
parent 34d97ed7c4
commit 66878544bf
2 changed files with 6 additions and 2 deletions

View File

@ -30,10 +30,13 @@ class ApplicationController < ActionController::Base
# obligatory '2001: A Space Odyssey' reference # obligatory '2001: A Space Odyssey' reference
flash[:notice] = t("user.sessions.create.banned", name:) flash[:notice] = t("user.sessions.create.banned", name:)
current_ban = current_user.bans.current.first current_ban = current_user.bans.current.first
unless current_ban&.reason.nil? unless current_ban&.reason.empty?
flash[:notice] += "\n#{t('user.sessions.create.reason', reason: current_ban.reason)}" flash[:notice] += "\n#{t('user.sessions.create.reason', reason: current_ban.reason)}"
end end
unless current_ban&.permanent?
if current_ban&.permanent?
flash[:notice] += "\n#{t('user.sessions.create.permanent')}"
else
# TODO format banned_until # TODO format banned_until
flash[:notice] += "\n#{t('user.sessions.create.until', time: current_ban.expires_at)}" flash[:notice] += "\n#{t('user.sessions.create.until', time: current_ban.expires_at)}"
end end

View File

@ -173,6 +173,7 @@ en:
sessions: sessions:
create: create:
banned: "I'm sorry, %{name}, I'm afraid I can't do that." banned: "I'm sorry, %{name}, I'm afraid I can't do that."
permanent: "You are banned permanently."
reason: "Ban reason: %{reason}" reason: "Ban reason: %{reason}"
until: "Banned until: %{time}" until: "Banned until: %{time}"
info: info: