From 75f27099be16a3ae5307bb1ee69b6ca2f4bcdad4 Mon Sep 17 00:00:00 2001 From: Askaholic Date: Mon, 1 Jan 2024 22:18:25 +0000 Subject: [PATCH] deploy: 999ce6fdd26ae9218f141d04dd296e237278a0c7 --- exceptions.html | 12 +++++-- lobbyconnection.html | 75 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 78 insertions(+), 9 deletions(-) diff --git a/exceptions.html b/exceptions.html index 8f1607de4..1112e9d20 100644 --- a/exceptions.html +++ b/exceptions.html @@ -63,7 +63,9 @@

Module server.exceptions

def message(self): return ( f"You are banned from FAF {self._ban_duration_text()}. <br>" - f"Reason: <br>{self.ban_reason}" + f"Reason: <br>{self.ban_reason}<br><br>" + "<i>If you would like to appeal this ban, please send an email to: " + "moderation@faforever.com</i>" ) def _ban_duration_text(self): @@ -152,7 +154,9 @@

Ancestors

def message(self): return ( f"You are banned from FAF {self._ban_duration_text()}. <br>" - f"Reason: <br>{self.ban_reason}" + f"Reason: <br>{self.ban_reason}<br><br>" + "<i>If you would like to appeal this ban, please send an email to: " + "moderation@faforever.com</i>" ) def _ban_duration_text(self): @@ -184,7 +188,9 @@

Methods

def message(self):
     return (
         f"You are banned from FAF {self._ban_duration_text()}. <br>"
-        f"Reason: <br>{self.ban_reason}"
+        f"Reason: <br>{self.ban_reason}<br><br>"
+        "<i>If you would like to appeal this ban, please send an email to: "
+        "moderation@faforever.com</i>"
     )
diff --git a/lobbyconnection.html b/lobbyconnection.html index cf3aa568e..67e69aab5 100644 --- a/lobbyconnection.html +++ b/lobbyconnection.html @@ -545,16 +545,37 @@

Module server.lobbyconnection

async with self._db.acquire() as conn: result = await conn.execute( - select(t_login.c.login) + select( + t_login.c.login, + lobby_ban.c.reason, + lobby_ban.c.expires_at + ) + .select_from(t_login.outerjoin(lobby_ban)) .where(t_login.c.id == player_id) + .order_by(lobby_ban.c.expires_at.desc()) ) row = result.fetchone() if not row: - self._logger.warning("User id not found in database possible fraudulent token: %s", player_id) + self._logger.warning( + "User id %s not found in database! Possible fraudulent " + "token: %s", + player_id, + token + ) raise AuthenticationError("Cannot find user id", auth_method) username = row.login + ban_reason = row.reason + ban_expiry = row.expires_at + + now = datetime.utcnow() + if ban_reason is not None and now < ban_expiry: + self._logger.debug( + "Rejected login from banned user: %s, %s, %s", + player_id, username, self.session + ) + raise BanError(ban_expiry, ban_reason) # DEPRECATED: IRC passwords are handled outside of the lobby server. # This message remains here for backwards compatibility, but the data @@ -1782,16 +1803,37 @@

Classes

async with self._db.acquire() as conn: result = await conn.execute( - select(t_login.c.login) + select( + t_login.c.login, + lobby_ban.c.reason, + lobby_ban.c.expires_at + ) + .select_from(t_login.outerjoin(lobby_ban)) .where(t_login.c.id == player_id) + .order_by(lobby_ban.c.expires_at.desc()) ) row = result.fetchone() if not row: - self._logger.warning("User id not found in database possible fraudulent token: %s", player_id) + self._logger.warning( + "User id %s not found in database! Possible fraudulent " + "token: %s", + player_id, + token + ) raise AuthenticationError("Cannot find user id", auth_method) username = row.login + ban_reason = row.reason + ban_expiry = row.expires_at + + now = datetime.utcnow() + if ban_reason is not None and now < ban_expiry: + self._logger.debug( + "Rejected login from banned user: %s, %s, %s", + player_id, username, self.session + ) + raise BanError(ban_expiry, ban_reason) # DEPRECATED: IRC passwords are handled outside of the lobby server. # This message remains here for backwards compatibility, but the data @@ -2860,16 +2902,37 @@

Methods

async with self._db.acquire() as conn: result = await conn.execute( - select(t_login.c.login) + select( + t_login.c.login, + lobby_ban.c.reason, + lobby_ban.c.expires_at + ) + .select_from(t_login.outerjoin(lobby_ban)) .where(t_login.c.id == player_id) + .order_by(lobby_ban.c.expires_at.desc()) ) row = result.fetchone() if not row: - self._logger.warning("User id not found in database possible fraudulent token: %s", player_id) + self._logger.warning( + "User id %s not found in database! Possible fraudulent " + "token: %s", + player_id, + token + ) raise AuthenticationError("Cannot find user id", auth_method) username = row.login + ban_reason = row.reason + ban_expiry = row.expires_at + + now = datetime.utcnow() + if ban_reason is not None and now < ban_expiry: + self._logger.debug( + "Rejected login from banned user: %s, %s, %s", + player_id, username, self.session + ) + raise BanError(ban_expiry, ban_reason) # DEPRECATED: IRC passwords are handled outside of the lobby server. # This message remains here for backwards compatibility, but the data