Skip to content

Commit

Permalink
fix modeus bug
Browse files Browse the repository at this point in the history
  • Loading branch information
depocoder committed Sep 23, 2024
1 parent 56b3052 commit 1ffb0a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 46 deletions.
17 changes: 8 additions & 9 deletions backend/integration/modeus.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def get_post_url(session: AsyncClient, token_length: int = 16) -> URL:
"nonce": token_hex(token_length),
"state": token_hex(token_length),
}
response = await session.get(auth_url, params=auth_data)
response = await session.get(auth_url, params=auth_data, follow_redirects=True)
# response.raise_for_status()
post_url = response.url
if post_url is None:
Expand All @@ -54,7 +54,7 @@ async def get_auth_form(session: AsyncClient, username: str, password: str) -> T
"Password": password,
"AuthMethod": "FormsAuthentication",
}
response = await session.post(post_url, data=login_data)
response = await session.post(post_url, data=login_data, follow_redirects=True)
# response.raise_for_status()
html_text = response.text

Expand All @@ -76,12 +76,11 @@ async def login(username: str, __password: str, timeout: int = 15) -> Dict[str,
Raises:
CannotAuthenticateError: if something changed in API
"""
session = AsyncClient(
http2=True,
base_url="https://utmn.modeus.org/",
timeout=timeout,
)

# with AsyncClient(http2=True, base_url="https://utmn.modeus.org/", timeout=timeout,) as session:
# pass
session = AsyncClient(http2=True, base_url="https://utmn.modeus.org/", timeout=timeout, headers={
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0',
}, follow_redirects=True,)
form = await get_auth_form(session, username, __password)
auth_data = {}
continue_auth_url = "https://auth.modeus.org/commonauth"
Expand All @@ -90,7 +89,7 @@ async def login(username: str, __password: str, timeout: int = 15) -> Dict[str,
response = await session.post(
continue_auth_url,
data=auth_data,
allow_redirects=False,
follow_redirects=False,
)
headers = {"Referer": "https://fs.utmn.ru/"}
auth_id = response.cookies.get("commonAuthId")
Expand Down
60 changes: 24 additions & 36 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requests = "^2.32.3"
undetected-chromedriver = "^3.5.5"
environs = "^11.0.0"
jwt = "^1.3.1"
httpx = {version = ">=0.19.0,<0.20.0", extras = ["http2"]}
httpx = {version = ">=0.19.0", extras = ["http2"]}
beautifulsoup4 = ">=4.10.0,<4.11.0"
blacksheep = {version = ">=2.0.0,<2.1.0", extras = ["full"]}
blacksheep-cli = "^0.0.4"
Expand Down

0 comments on commit 1ffb0a9

Please sign in to comment.