Skip to content

Commit

Permalink
fix: ensure login page works without socialaccount (#47)
Browse files Browse the repository at this point in the history
Fixes #44
  • Loading branch information
danihodovic authored May 21, 2024
1 parent e142650 commit 91a5ccf
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 39 deletions.
17 changes: 4 additions & 13 deletions allauth_ui/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends "account/base.html" %}
{% load i18n %}
{% load widget_tweaks %}
{% load account socialaccount %}
{% load i18n account allauth_ui widget_tweaks %}

{% block head_title %}
{% translate "Sign in" %}
Expand Down Expand Up @@ -46,18 +44,11 @@ <h1 class="mb-5 text-3xl text-center">Sign in</h1>
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
</form>
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<div class="flex items-center self-stretch justify-between pt-3 mt-3">
<hr class="w-full">
<span class="p-2 mb-1 text-gray-400">OR</span>
<hr class="w-full">
</div>

<p class="text-xs text-center text-gray-500">{% translate "Sign in with a third party" %}</p>

{% include "socialaccount/snippets/provider_list.html" with process="login" %}
{% check_allauth_socialaccount_installed as is_allauth_socialaccount_installed %}
{% if is_allauth_socialaccount_installed %}
{% include "socialaccount/snippets/social_login.html" %}
{% endif %}

{% include "socialaccount/snippets/login_extra.html" %}
{% endblock %}
14 changes: 14 additions & 0 deletions allauth_ui/templates/socialaccount/snippets/social_login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load socialaccount i18n %}
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<div class="flex items-center self-stretch justify-between pt-3 mt-3">
<hr class="w-full">
<span class="p-2 mb-1 text-gray-400">OR</span>
<hr class="w-full">
</div>

<p class="text-xs text-center text-gray-500">{% translate "Sign in with a third party" %}</p>

{% include "socialaccount/snippets/provider_list.html" with process="login" %}
{% include "socialaccount/snippets/login_extra.html" %}
{% endif %}
7 changes: 6 additions & 1 deletion allauth_ui/templatetags/allauth_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

from django import template

from django.conf import settings

register = template.Library()

Expand All @@ -22,3 +22,8 @@ def socialprovider_color(socialprovider):
if name in social_colors:
return f"social-{name}"
return "bg-stone-900 hover:bg-black"


@register.simple_tag
def check_allauth_socialaccount_installed():
return "allauth.socialaccount" in settings.INSTALLED_APPS
Loading

0 comments on commit 91a5ccf

Please sign in to comment.