mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-03 15:05:11 -04:00
Refuses connection if another session is already active
This commit is contained in:
parent
e9e2afe2ee
commit
132bbb0db9
1 changed files with 15 additions and 12 deletions
|
@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import request, render_template, make_response, jsonify, session
|
from flask import request, render_template, make_response, jsonify, session
|
||||||
from flask_socketio import emit
|
from flask_socketio import emit, ConnectionRefusedError
|
||||||
|
|
||||||
|
|
||||||
class ChatModeWeb:
|
class ChatModeWeb:
|
||||||
|
@ -117,6 +117,7 @@ class ChatModeWeb:
|
||||||
def server_connect():
|
def server_connect():
|
||||||
"""Sent by clients when they enter a room.
|
"""Sent by clients when they enter a room.
|
||||||
A status message is broadcast to all people in the room."""
|
A status message is broadcast to all people in the room."""
|
||||||
|
if self.validate_username(session.get("name")):
|
||||||
self.connected_users.append(session.get("name"))
|
self.connected_users.append(session.get("name"))
|
||||||
emit(
|
emit(
|
||||||
"status",
|
"status",
|
||||||
|
@ -128,6 +129,8 @@ class ChatModeWeb:
|
||||||
},
|
},
|
||||||
broadcast=True,
|
broadcast=True,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
raise ConnectionRefusedError('You are active from another session!')
|
||||||
|
|
||||||
@self.web.socketio.on("text", namespace="/chat")
|
@self.web.socketio.on("text", namespace="/chat")
|
||||||
def text(message):
|
def text(message):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue