summaryrefslogtreecommitdiff
path: root/cli/onionshare_cli/web/chat_mode.py
diff options
context:
space:
mode:
Diffstat (limited to 'cli/onionshare_cli/web/chat_mode.py')
-rw-r--r--cli/onionshare_cli/web/chat_mode.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/cli/onionshare_cli/web/chat_mode.py b/cli/onionshare_cli/web/chat_mode.py
index 8b2a5673..e9b573dd 100644
--- a/cli/onionshare_cli/web/chat_mode.py
+++ b/cli/onionshare_cli/web/chat_mode.py
@@ -79,20 +79,33 @@ class ChatModeWeb:
if (
data.get("username", "")
and data.get("username", "") not in self.connected_users
+ and len(data.get("username", "")) < 128
):
session["name"] = data.get("username", session.get("name"))
- self.web.add_request(
- request.path,
- {"id": history_id, "status_code": 200},
- )
+ self.web.add_request(
+ request.path,
+ {"id": history_id, "status_code": 200},
+ )
- self.web.add_request(self.web.REQUEST_LOAD, request.path)
- r = make_response(
- jsonify(
- username=session.get("name"),
- success=True,
+ self.web.add_request(self.web.REQUEST_LOAD, request.path)
+ r = make_response(
+ jsonify(
+ username=session.get("name"),
+ success=True,
+ )
+ )
+ else:
+ self.web.add_request(
+ request.path,
+ {"id": history_id, "status_code": 403},
+ )
+
+ r = make_response(
+ jsonify(
+ username=session.get("name"),
+ success=False,
+ )
)
- )
return self.web.add_security_headers(r)
@self.web.socketio.on("joined", namespace="/chat")