Skip to content

Commit

Permalink
fix qr code login url creation
Browse files Browse the repository at this point in the history
The regex was incorrectly replacing old query parameters.

closes #299
  • Loading branch information
bain3 committed Jul 2, 2024
1 parent 9d9e000 commit e25e194
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pronotepy/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
)

from Crypto.Hash import SHA256
from uuid import uuid4
import re
import urllib
from urllib.parse import urlparse, urlunparse

from . import dataClasses
from .exceptions import *
Expand All @@ -33,8 +32,7 @@
from typing_extensions import Protocol

class ENTFunction(Protocol):
def __call__(self, u: str, p: str, **kwargs: str) -> RequestsCookieJar:
...
def __call__(self, u: str, p: str, **kwargs: str) -> RequestsCookieJar: ...


__all__ = ("ClientBase", "Client", "ParentClient", "VieScolaireClient")
Expand Down Expand Up @@ -151,11 +149,10 @@ def qrcode_login(cls: Type[T], qr_code: dict, pin: str, uuid: str) -> T:
# Add magic parameters at the end of the URL. You can find them in a
# file called "ObjetCommMessage.js" in the connection method when you
# decompile the mobile APK.
url = re.sub(
r"(\?.*)|( *)$",
"?bydlg=A6ABB224-12DD-4E31-AD3E-8A39A1C2C335&login=true",
qr_code["url"],
0,
url: str = urlunparse(
urlparse(qr_code["url"])._replace(
query="fd=1&bydlg=A6ABB224-12DD-4E31-AD3E-8A39A1C2C335&login=true"
)
)

return cls(url, login, jeton, mode="qr_code", uuid=uuid)
Expand Down Expand Up @@ -199,9 +196,9 @@ def _login(self) -> bool:
"demandeConnexionAppliMobile": self.login_mode == "qr_code",
"demandeConnexionAppliMobileJeton": self.login_mode == "qr_code",
"enConnexionAppliMobile": self.login_mode == "token",
"uuidAppliMobile": self.uuid
if self.login_mode in ("qr_code", "token")
else "",
"uuidAppliMobile": (
self.uuid if self.login_mode in ("qr_code", "token") else ""
),
"loginTokenSAV": "",
}
idr = self.post("Identification", data=ident_json)
Expand Down

0 comments on commit e25e194

Please sign in to comment.