mirror of https://github.com/zulip/zulip.git
auth: GitHubAuthBackend.get_verified_emails returns user's all emails.
The email_list returned has the primary email as the first element. Testing: The order of the emails in the test was changed to put a verified email before the primary one. The tests would fail without this commit's change after the changes in the order of test emails.
This commit is contained in:
parent
2fa77d9d54
commit
d95364b94f
|
@ -477,14 +477,18 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
||||||
primary=True),
|
primary=True),
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
# Keeping a verified email before the primary email makes sure
|
||||||
|
# get_verified_emails puts the primary email at the start of the
|
||||||
|
# email list returned as social_associate_user_helper assumes the
|
||||||
|
# first email as the primary email.
|
||||||
email_data = [
|
email_data = [
|
||||||
|
dict(email="notprimary@example.com",
|
||||||
|
verified=True),
|
||||||
dict(email=account_data_dict["email"],
|
dict(email=account_data_dict["email"],
|
||||||
verified=True,
|
verified=True,
|
||||||
primary=True),
|
primary=True),
|
||||||
dict(email="ignored@example.com",
|
dict(email="ignored@example.com",
|
||||||
verified=False),
|
verified=False),
|
||||||
dict(email="notprimary@example.com",
|
|
||||||
verified=True),
|
|
||||||
]
|
]
|
||||||
# We register callbacks for the key URLs on github.com that
|
# We register callbacks for the key URLs on github.com that
|
||||||
# /complete/github will call
|
# /complete/github will call
|
||||||
|
|
|
@ -598,13 +598,15 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
|
||||||
# case without any verified emails
|
# case without any verified emails
|
||||||
emails = []
|
emails = []
|
||||||
|
|
||||||
verified_emails = []
|
verified_emails = [] # type: List[str]
|
||||||
for email_obj in emails:
|
for email_obj in emails:
|
||||||
if not email_obj.get("verified"):
|
if not email_obj.get("verified"):
|
||||||
continue
|
continue
|
||||||
# TODO: When we add a screen to let the user select an email, remove this line.
|
# social_associate_user_helper assumes that the first email in
|
||||||
if not email_obj.get("primary"):
|
# verified_emails is primary.
|
||||||
continue
|
if email_obj.get("primary"):
|
||||||
|
verified_emails.insert(0, email_obj["email"])
|
||||||
|
else:
|
||||||
verified_emails.append(email_obj["email"])
|
verified_emails.append(email_obj["email"])
|
||||||
|
|
||||||
return verified_emails
|
return verified_emails
|
||||||
|
|
Loading…
Reference in New Issue