Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 8dd39b3

Browse files
committed
Fix cookie caching
1 parent cfc3b1a commit 8dd39b3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

vrcpy/client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def login(self, username, password):
271271
resp = self.api.call("/auth/user", headers={"Authorization": "Basic "+auth}, no_auth=True)
272272

273273
self.api.set_auth(auth)
274+
self.api.session.cookies.set("auth", resp["response"].cookies["auth"])
275+
274276
self.me = objects.CurrentUser(self, resp["data"])
275277
self.loggedIn = True
276278

@@ -304,6 +306,12 @@ def login2fa(self, username, password, code=None, verify=False):
304306
try:
305307
resp = self.api.call("/auth/user", headers={"Authorization": "Basic "+auth}, no_auth=True, verify=False)
306308
raise_for_status(resp)
309+
310+
self.api.set_auth(auth)
311+
self.api.session.cookies.set("auth", resp["response"].cookies["auth"])
312+
313+
self.me = objects.CurrentUser(self, resp["data"])
314+
self.loggedIn = True
307315
except RequiresTwoFactorAuthError:
308316
self.api.set_auth(auth)
309317
self.api.session.cookies.set("auth", resp["response"].cookies["auth"]) # Auth cookieeee
@@ -593,6 +601,8 @@ async def login(self, username, password):
593601
resp = await self.api.call("/auth/user", headers={"Authorization": "Basic "+auth}, no_auth=True)
594602

595603
self.api.openSession(auth)
604+
self.api.session.cookie_jar.update_cookies([["auth", resp["response"].headers["Set-Cookie"].split(';')[0].split("=")[1]]])
605+
596606
self.me = aobjects.CurrentUser(self, resp["data"])
597607
self.loggedIn = True
598608

@@ -628,6 +638,14 @@ async def login2fa(self, username, password, code=None, verify=False):
628638
try:
629639
resp = await self.api.call("/auth/user", headers={"Authorization": "Basic "+auth}, no_auth=True, verify=False)
630640
raise_for_status(resp)
641+
642+
self.api.openSession(auth)
643+
self.api.session.cookie_jar.update_cookies([["auth", resp["response"].headers["Set-Cookie"].split(';')[0].split("=")[1]]])
644+
645+
self.me = aobjects.CurrentUser(self, resp["data"])
646+
self.loggedIn = True
647+
648+
await self.me.cacheTask
631649
except RequiresTwoFactorAuthError:
632650
self.api.openSession(auth)
633651
self.api.session.cookie_jar.update_cookies([["auth", resp["response"].headers["Set-Cookie"].split(';')[0].split("=")[1]]])

0 commit comments

Comments
 (0)