Skip to content

Commit

Permalink
Update Login.login_auto() according to the EduPage changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BelKed committed Feb 15, 2024
1 parent 1477e77 commit 6ecc342
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions edupage_api/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ def login_auto(self, username: str, password: str):
BadCredentialsException: Your credentials are invalid.
"""

response = self.edupage.session.get("https://login1.edupage.org")
data = response.content.decode()
csrf_token = data.split('name="csrfauth" value="')[1].split('"')[0]

parameters = {
"meno": username,
"heslo": password,
"akcia": "login"
"csrfauth": csrf_token,
"username": username,
"password": password,
}

request_url = "https://portal.edupage.org/index.php?jwid=jw2&module=login"
response = self.edupage.session.post(request_url, params=parameters)
request_url = "https://login1.edupage.org/login/edubarLogin.php"
response = self.edupage.session.post(request_url, parameters)
data = response.content.decode()

if "wrongPassword" in response.url or "errorbox" in data:
if "bad=1" in response.url:
raise BadCredentialsException()

self.__parse_login_data(data)
Expand Down

0 comments on commit 6ecc342

Please sign in to comment.