Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Get rid of not configured social buttons

Adam Bogdalfb0263003194
diff --git a/saleor/registration/templates/registration/login.html b/saleor/registration/templates/registration/login.html
index 08cd43678e..9ad575fbd3 100644
--- a/saleor/registration/templates/registration/login.html
+++ b/saleor/registration/templates/registration/login.html
@@ -22,16 +22,22 @@
</div>
</div>
<hr>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <p>{% trans "Want to use your social profile?" %}</p>
- <p>
- <a class="btn btn-default zocial-facebook" href="{{ facebook_login_url }}"> {% trans "Log in using Facebook" %}</a>
- <a class="btn btn-default zocial-google" href="{{ google_login_url }}"> {% trans "Log in using Google" %}</a>
- </p>
+ {% if facebook_login_url or google_login_url %}
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <p>{% trans "Want to use your social profile?" %}</p>
+ <p>
+ {% if facebook_login_url %}
+ <a class="btn btn-default zocial-facebook" href="{{ facebook_login_url }}"> {% trans "Log in using Facebook" %}</a>
+ {% endif %}
+ {% if google_login_url %}
+ <a class="btn btn-default zocial-google" href="{{ google_login_url }}"> {% trans "Log in using Google" %}</a>
+ {% endif %}
+ </p>
+ </div>
</div>
- </div>
- <hr>
+ <hr>
+ {% endif %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<p>{% trans "Don't have an account yet?" %} <a class="btn btn-secondary" href="{% url 'registration:request_email_confirmation' %}">{% trans "Register" %}</a></p>
diff --git a/saleor/registration/views.py b/saleor/registration/views.py
index c4755f9c67..70ee6ddf08 100644
--- a/saleor/registration/views.py
+++ b/saleor/registration/views.py
@@ -27,8 +27,11 @@ now = timezone.now
def login(request):
local_host = utils.get_local_host(request)
- ctx = {'facebook_login_url': utils.get_facebook_login_url(local_host),
- 'google_login_url': utils.get_google_login_url(local_host)}
+ ctx = {}
+ if settings.FACEBOOK_APP_ID:
+ ctx['facebook_login_url'] = utils.get_facebook_login_url(local_host)
+ if settings.GOOGLE_CLIENT_ID:
+ ctx['google_login_url'] = utils.get_google_login_url(local_host)
return django_login_view(request, authentication_form=forms.LoginForm,
extra_context=ctx)