Skip to content

Commit 247a0fb

Browse files
committed
fix(vk): improve error handling
- check vk_api return value - simplified response generating to avoid intermediate dictionary
1 parent 66e4d9e commit 247a0fb

File tree

1 file changed

+13
-14
lines changed
  • social_core/backends

1 file changed

+13
-14
lines changed

social_core/backends/vk.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,20 @@ def auth_complete(self, *args, **kwargs):
196196
if user_check == 1:
197197
is_user = self.data.get("is_app_user")
198198
elif user_check == 2:
199-
is_user = self.vk_api("isAppUser", {"user_id": user_id}).get(
200-
"response", 0
201-
)
199+
response = self.vk_api("isAppUser", {"user_id": user_id})
200+
if response is None:
201+
return None
202+
is_user = response.get("response", 0)
202203
if not int(is_user):
203204
return None
204205

205-
auth_data = {
206-
"auth": self,
207-
"backend": self,
208-
"request": self.strategy.request_data(),
209-
"response": {
210-
self.id_key(): user_id,
211-
},
212-
}
213-
auth_data["response"].update(
214-
json.loads(auth_data["request"]["api_result"])["response"][0]
206+
request = self.strategy.request_data()
207+
response = {self.id_key(): user_id}
208+
response.update(json.loads(request["api_result"])["response"][0])
209+
return self.strategy.authenticate(
210+
*args,
211+
auth=self,
212+
backend=self,
213+
request=request,
214+
response=response,
215215
)
216-
return self.strategy.authenticate(*args, **auth_data)

0 commit comments

Comments
 (0)