Skip to content

Commit

Permalink
Fix channel authentication call. The pusher>=1.0 changed how it works.
Browse files Browse the repository at this point in the history
  • Loading branch information
iurisilvio committed Apr 25, 2015
1 parent a9fff89 commit e64c3e9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flask_pusher.py
Expand Up @@ -111,18 +111,27 @@ def _auth_buffered(self, socket_id):
return response

def _auth_key(self, socket_id, channel_name):
channel = self.client[channel_name]
if channel_name.startswith("presence-"):
channel_data = {"user_id": socket_id}
if self._channel_data_handler:
d = self._channel_data_handler(channel_name, socket_id)
channel_data.update(d)
auth = channel.authenticate(socket_id, channel_data)
auth_args = [socket_id, channel_data]
elif channel_name.startswith("private-"):
auth = channel.authenticate(socket_id)
auth_args = [socket_id]
else:
# must never happen, this request is not from pusher
abort(404)

try:
channel = self.client[channel_name]
except TypeError:
# pusher>=1.0
auth = self.client.authenticate(channel_name, *auth_args)
else:
# pusher<1.0
auth = channel.authenticate(*auth_args)

return auth


Expand Down

0 comments on commit e64c3e9

Please sign in to comment.