From 79e590f50faf7e640cf0df392f66a11fd2bdce4e Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Tue, 10 Jul 2018 15:59:06 +0530 Subject: [PATCH] auth: Store realm id in return_data of social_associate_user_helper. Realm object is not json-serializable; store the realm id instead and retrieve the realm in social_auth_finish using `Realm.objects.get(id=return_data["realm_id"])`. --- zproject/backends.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zproject/backends.py b/zproject/backends.py index 102cc464aa..ebacd01e30 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -432,7 +432,7 @@ def social_associate_user_helper(backend: BaseAuth, return_data: Dict[str, Any], if realm is None: return_data["invalid_realm"] = True return None - return_data["realm"] = realm + return_data["realm_id"] = realm.id if not auth_enabled_helper([backend.auth_backend_name], realm): return_data["auth_backend_disabled"] = True @@ -545,7 +545,7 @@ def social_auth_finish(backend: Any, full_name = return_data['full_name'] is_signup = strategy.session_get('is_signup') == '1' redirect_to = strategy.session_get('next') - realm = return_data["realm"] + realm = Realm.objects.get(id=return_data["realm_id"]) mobile_flow_otp = strategy.session_get('mobile_flow_otp') if mobile_flow_otp is not None: