auth: Reverse the `sort_order` parameter's semantics.

This will make sure that if a backend doesn't specify a values for
`sort_order` parameter then it will sorted to the bottom not at the
top.
This commit is contained in:
Harshit Bansal 2019-03-10 08:38:20 +00:00 committed by Tim Abbott
parent 412d35900f
commit 262eb42b77
2 changed files with 5 additions and 4 deletions

View File

@ -162,6 +162,6 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
'signup_url': reverse('signup-social', args=(backend.name,)),
'sort_order': backend.sort_order,
})
context['social_backends'] = sorted(social_backends, key=lambda x: x['sort_order'])
context['social_backends'] = sorted(social_backends, key=lambda x: x['sort_order'], reverse=True)
return context

View File

@ -825,7 +825,8 @@ def social_auth_finish(backend: Any,
class SocialAuthMixin(ZulipAuthMixin):
auth_backend_name = "undeclared"
# Used to determine how to order buttons on login form
# Used to determine how to order buttons on login form, backend with
# higher sort order are displayed first.
sort_order = 0
def auth_complete(self, *args: Any, **kwargs: Any) -> Optional[HttpResponse]:
@ -853,7 +854,7 @@ class SocialAuthMixin(ZulipAuthMixin):
class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
auth_backend_name = "GitHub"
sort_order = 50
sort_order = 100
def get_verified_emails(self, *args: Any, **kwargs: Any) -> List[str]:
access_token = kwargs["response"]["access_token"]
@ -905,7 +906,7 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
raise AssertionError("Invalid configuration")
class AzureADAuthBackend(SocialAuthMixin, AzureADOAuth2):
sort_order = 100
sort_order = 50
auth_backend_name = "AzureAD"
AUTH_BACKEND_NAME_MAP = {