aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/onionshare_cli/web/chat_mode.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cli/onionshare_cli/web/chat_mode.py b/cli/onionshare_cli/web/chat_mode.py
index 02466e2b..85eb94ff 100644
--- a/cli/onionshare_cli/web/chat_mode.py
+++ b/cli/onionshare_cli/web/chat_mode.py
@@ -76,12 +76,16 @@ class ChatModeWeb:
)
def validate_username(self, username):
- username = self.remove_unallowed_characters(username.strip())
- return (
- username
- and username not in self.connected_users
- and len(username) < 128
- )
+ try:
+ username = self.remove_unallowed_characters(username.strip())
+ return (
+ username
+ and username not in self.connected_users
+ and len(username) < 128
+ )
+ except Exception as e:
+ self.common.log("ChatModeWeb", "validate_username", e)
+ return False
def define_routes(self):
"""
@@ -160,7 +164,7 @@ class ChatModeWeb:
broadcast=True,
)
else:
- raise ConnectionRefusedError('You are active from another session!')
+ raise ConnectionRefusedError('Invalid session')
@self.web.socketio.on("text", namespace="/chat")
def text(message):