Sunday, March 26, 2017

Channels - logout not resetting message.user value on new WebSocket connections

Hello,

I'm trying out Channels in Django 1.11 and set up a few consumers, looking like this:

@channel_session_user_from_http
def ws_connect(message, slug):
   
if message.user.is_authenticated():
         message
.reply_channel.send({"accept": True})
   
else:
         message
.reply_channel.send({"accept": False})

And it works before logging in; the connection is closed and dropped when the user is logged out. Once logged in, it begins accepting socket connections.

Then, I hit `accounts/logout` (the default login view), and everything logs out. I can't view protected (login_required) views anymore, and it seems like everything was unset properly.

However, when I open up the console and fire another websocket request, the request passes the is_authenticated check and enters with the old logged out user, as if it was not cleared. This only happens within channels, every other part of the site is logged out, but this seems to retain the session and not clear it.

Is there any solution to this, am I approaching this wrong, or is this a known issue?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ad49c85d-78f0-4420-acdf-c84ff02524b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment