From 267e56ce2afe2959c7aa3d2534727d4602dc8ab8 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 20 Feb 2016 22:47:48 +0000 Subject: [PATCH] Make transfer_user fail silently if no user --- channels/auth.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/channels/auth.py b/channels/auth.py index 1ae7e1d..a8c8a05 100644 --- a/channels/auth.py +++ b/channels/auth.py @@ -10,9 +10,10 @@ def transfer_user(from_session, to_session): """ Transfers user from HTTP session to channel session. """ - to_session[auth.BACKEND_SESSION_KEY] = from_session[auth.BACKEND_SESSION_KEY] - to_session[auth.SESSION_KEY] = from_session[auth.SESSION_KEY] - to_session[auth.HASH_SESSION_KEY] = from_session[auth.HASH_SESSION_KEY] + if auth.BACKEND_SESSION_KEY in from_session and auth.SESSION_KEY in from_session and auth.HASH_SESSION_KEY in from_session: + to_session[auth.BACKEND_SESSION_KEY] = from_session[auth.BACKEND_SESSION_KEY] + to_session[auth.SESSION_KEY] = from_session[auth.SESSION_KEY] + to_session[auth.HASH_SESSION_KEY] = from_session[auth.HASH_SESSION_KEY] def channel_session_user(func):