refactor: De-duplicate code in `accounts_home.html` for social auth.

This commit is contained in:
Harshit Bansal 2019-03-05 17:39:17 +00:00 committed by Tim Abbott
parent 3610aaece3
commit 0be410d3fe
2 changed files with 5 additions and 4 deletions

View File

@ -87,16 +87,16 @@ $(function () {
</div>
{% endif %}
{% if github_auth_enabled %}
{% for backend in social_backends %}
<div class="login-social">
<form class="form-inline github-wrapper" action="{{ url('signup-social', args=('github',)) }}" method="get">
<form class="form-inline {{ backend.name }}-wrapper" action="{{ backend.signup_url }}" method="get">
<input type='hidden' name='multiuse_object_key' value='{{ multiuse_object_key }}' />
<button class="login-social-button full-width">
{{ _('Sign up with %(identity_provider)s', identity_provider="GitHub") }}
{{ _('Sign up with %(identity_provider)s', identity_provider=backend.display_name) }}
</button>
</form>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
</div>

View File

@ -158,6 +158,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
'name': backend.name,
'display_name': backend.auth_backend_name,
'login_url': reverse('login-social', args=(backend.name,)),
'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'])