Skip to content

Commit

Permalink
Update GitHub email queries
Browse files Browse the repository at this point in the history
  • Loading branch information
iojw committed Jul 21, 2020
1 parent aec8b71 commit 3ee8105
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion socialscan/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
13 changes: 5 additions & 8 deletions socialscan/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class GitHub(PlatformChecker):
USERNAME_LINK_FORMAT = "https://github.com/{}"

token_regex = re.compile(
r'<auto-check src="/signup_check/username[\s\S]*value="([\S]*)"[\s\S]*<auto-check src="/signup_check/email[\s\S]*value="([\S]*)"[\s\S]*</auto-check>'
r'<auto-check src="/signup_check/username[\s\S]*?value="([\S]+)"[\s\S]*<auto-check src="/signup_check/email[\s\S]*?value="([\S]+)"'
)
tag_regex = re.compile(r"<[^>]+>")

Expand All @@ -251,15 +251,14 @@ async def prerequest(self):
if match:
username_token = match.group(1)
email_token = match.group(2)
return (username_token, email_token, {"_gh_sess": r.cookies["_gh_sess"]})
return (username_token, email_token)

async def check_username(self, username):
pr = await self.get_token()
(username_token, _, cookies) = pr
(username_token, _) = pr
async with self.post(
GitHub.USERNAME_ENDPOINT,
data={"value": username, "authenticity_token": username_token},
cookies=cookies,
) as r:
if r.status == 422:
text = await r.text()
Expand All @@ -282,11 +281,9 @@ async def check_email(self, email):
if pr is None:
return self.response_failure(email, message=PlatformChecker.TOKEN_ERROR_MESSAGE)
else:
(_, email_token, cookies) = pr
(_, email_token) = pr
async with self.post(
GitHub.EMAIL_ENDPOINT,
data={"value": email, "authenticity_token": email_token},
cookies=cookies,
GitHub.EMAIL_ENDPOINT, data={"value": email, "authenticity_token": email_token},
) as r:
if r.status == 422:
text = await r.text()
Expand Down

0 comments on commit 3ee8105

Please sign in to comment.