From ce34484c210c3e32fcde357d4baf6129ee94b1ca Mon Sep 17 00:00:00 2001 From: RaidTheWeb Date: Sun, 6 Dec 2020 10:37:08 +1300 Subject: [PATCH] Update __init__.py --- repltalk/__init__.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/repltalk/__init__.py b/repltalk/__init__.py index ac74e04..fe6177e 100644 --- a/repltalk/__init__.py +++ b/repltalk/__init__.py @@ -1009,6 +1009,33 @@ async def login(self, username, password): connectsid = str(dict(r.cookies)['connect.sid'].value) self.sid = connectsid return self + async def login_old(self, username, password): + if username.lower() not in whitelisted_bots: + raise NotWhitelisted( + f'{username} is not whitelisted and therefore is not allowed to log in.\n' + 'Please ask mat#6207 if you would like to be added to the whitelist.' + ) + + async with aiohttp.ClientSession( + headers={'referer': self.default_ref} + ) as s: + async with s.post( + base_url + '/login', + json={ + 'username': username, + 'password': password, + 'teacher': False + }, + headers={ + 'X-Requested-With': username + } + ) as r: + if await r.text() == '{"message":"Invalid username or password."}': + raise InvalidLogin('Invalid username or password.') + # Gets the connect.sid cookie + connectsid = str(dict(r.cookies)['connect.sid'].value) + self.sid = connectsid + return self async def _get_reports(self, resolved): reports = await self.perform_graphql(