Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for python bytes-to-utf-8 encoded string in the usernames #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions servers/python/coweb/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ class SessionConnection(bayeux.BayeuxConnection):
'''Connection for uncollaborative sessions.'''
def on_auth_ext(self, cl, auth):
'''Overrides to use cookie + db for Bayeux authentication.'''
username = self._handler.current_user
username = self._handler.current_user.decode('utf-8')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This edit may not add/remove anything as the session worked identically for me with or without the change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The username variable appears to not be used if you follow the function calls. But, your change is correct; this was an oversight related to python2/3 and the new version of Tornado conversions.

if username is None: return False
# check credentials in the db
return self._manager.authorize_user(username)

def on_handshake(self, cl, req, res):
'''Overrides to attach authed username to client.'''
if res['successful']:
cl.username = self._handler.current_user
cl.username = self._handler.current_user.decode('utf-8')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This edit is the change that solved the problem. Without it no sessions could be joined by the >1 client.


def on_unknown_client(self, res):
'''Overrides to prevent reconnects from dead clients.'''
Expand Down