Skip to content

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

Check login links in the registration App

Michał Ociepka2aed2dd1e3b9
diff --git a/saleor/registration/utils.py b/saleor/registration/utils.py
index 7b00ed6493..664a67800d 100644
--- a/saleor/registration/utils.py
+++ b/saleor/registration/utils.py
@@ -31,11 +31,15 @@ def get_client_class_for_service(service):
def get_google_login_url(local_host):
- return get_client_class_for_service(GOOGLE)(local_host).get_login_uri()
+ if settings.GOOGLE_CLIENT_ID:
+ client_class = get_client_class_for_service(GOOGLE)(local_host)
+ return client_class.get_login_uri()
def get_facebook_login_url(local_host):
- return get_client_class_for_service(FACEBOOK)(local_host).get_login_uri()
+ if settings.FACEBOOK_APP_ID:
+ client_class = get_client_class_for_service(FACEBOOK)(local_host)
+ return client_class.get_login_uri()
def parse_response(response):
diff --git a/saleor/registration/views.py b/saleor/registration/views.py
index 70ee6ddf08..4e600d4016 100644
--- a/saleor/registration/views.py
+++ b/saleor/registration/views.py
@@ -27,11 +27,9 @@ now = timezone.now
def login(request):
local_host = utils.get_local_host(request)
- 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)
+ ctx = {
+ 'facebook_login_url': utils.get_facebook_login_url(local_host),
+ 'google_login_url': utils.get_google_login_url(local_host)}
return django_login_view(request, authentication_form=forms.LoginForm,
extra_context=ctx)