Skip to content

Commit

Permalink
change social logins to use post
Browse files Browse the repository at this point in the history
start the social login process with a POST, not a GET; this saves the
user from seeing a secondary page that uses POST.
  • Loading branch information
longhotsummer committed Jan 20, 2025
1 parent 3647062 commit 84ce2d1
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions indigo_app/templates/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,27 @@ <h1 class="mb-3">{% trans 'Log In' %}</h1>
{% endif %}
</div>

<div class="row">
<div class="col-md-6">
<button class="btn btn-success btn-block mb-3" type="submit">{% trans 'Log in' %}</button>
</div>

<div class="col-md-6">
<a class="btn btn-outline-primary btn-block mb-3" href="{{ signup_url }}">{% trans 'Sign up' %}</a>
</div>
<div>
<button class="btn btn-success btn-block mb-3 me-3" type="submit">{% trans 'Log in' %}</button>
<a class="btn btn-outline-primary btn-block mb-3" href="{{ signup_url }}">{% trans 'Sign up' %}</a>
</div>
</form>

{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<hr class="my-4">
{% endif %}
{% for provider in socialaccount_providers %}
<form method="POST" class="mt-4" action="{% provider_login_url provider.id process='login' %}">
{% csrf_token %}
<button class="btn btn-block btn-outline-primary mb-3 socialaccount_provider {{provider.id}}" type="submit">
{% if provider.name == "Google" %}
<img src="{% static 'images/google-logo.png' %}" style="height: 20px; margin-right: 5px">
{% else %}
<i class="fab fa-fw fa-{{ provider.id }}"></i>
{% endif %}

<div class="row">
<div class="col-lg-7 mx-auto">
{% for provider in socialaccount_providers %}
<a class="btn btn-block btn-outline-primary mb-3 socialaccount_provider {{provider.id}}" href="{% provider_login_url provider.id process='login' %}">
{% if provider.name == "Google" %}
<img src="{% static 'images/google-logo.png' %}" style="height: 20px; margin-right: 5px">
{% else %}
<i class="fab fa-fw fa-{{ provider.id }}"></i>
{% endif %}

{% blocktrans with provider=provider.name %}Log in with {{provider}}{% endblocktrans %}
</a>
{% endfor %}
</div>
</div>
{% blocktrans with provider=provider.name %}Log in with {{provider}}{% endblocktrans %}
</button>
</form>
{% endfor %}

<div class="mt-3 text-muted text-center">
{% url 'terms_of_use' as tos_url %}
Expand Down

0 comments on commit 84ce2d1

Please sign in to comment.