Skip to content

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

Reorganize authentication backends

Mira Szewczykabc08f8fb40c
diff --git a/saleor/registration/backends/facebook.py b/saleor/registration/backends/facebook.py
index 5e9f96a22b..b372ac016e 100644
--- a/saleor/registration/backends/facebook.py
+++ b/saleor/registration/backends/facebook.py
@@ -1,8 +1,8 @@
from social_core.backends.facebook import FacebookOAuth2
from . import BaseBackend
-from ...site.models import FACEBOOK
+from ...site import AuthenticationBackends
class CustomFacebookOAuth2(BaseBackend, FacebookOAuth2):
- DB_NAME = FACEBOOK
+ DB_NAME = AuthenticationBackends.FACEBOOK
diff --git a/saleor/registration/backends/google.py b/saleor/registration/backends/google.py
index 9bfca049a0..6c8e205b95 100644
--- a/saleor/registration/backends/google.py
+++ b/saleor/registration/backends/google.py
@@ -1,8 +1,8 @@
from social_core.backends.google import GoogleOAuth2
from . import BaseBackend
-from ...site.models import GOOGLE
+from ...site import AuthenticationBackends
class CustomGoogleOAuth2(BaseBackend, GoogleOAuth2):
- DB_NAME = GOOGLE
+ DB_NAME = AuthenticationBackends.GOOGLE
diff --git a/saleor/site/__init__.py b/saleor/site/__init__.py
index e69de29bb2..2739f52689 100644
--- a/saleor/site/__init__.py
+++ b/saleor/site/__init__.py
@@ -0,0 +1,7 @@
+class AuthenticationBackends:
+ GOOGLE = 'google-oauth2'
+ FACEBOOK = 'facebook'
+
+ BACKENDS = (
+ (FACEBOOK, 'Facebook-Oauth2'),
+ (GOOGLE, 'Google-Oauth2'))
diff --git a/saleor/site/models.py b/saleor/site/models.py
index d75b5b9bb4..405d4256e1 100644
--- a/saleor/site/models.py
+++ b/saleor/site/models.py
@@ -3,11 +3,7 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import pgettext_lazy
-
-GOOGLE = 'google-oauth2'
-FACEBOOK = 'facebook'
-
-BACKENDS = [(FACEBOOK, 'Facebook-Oauth2'), (GOOGLE, 'Google-Oauth2')]
+from . import AuthenticationBackends
@python_2_unicode_compatible
@@ -35,7 +31,7 @@ class AuthorizationKey(models.Model):
site_settings = models.ForeignKey(SiteSettings)
name = models.CharField(
pgettext_lazy('Authentiaction field', 'name'), max_length=20,
- choices=BACKENDS)
+ choices=AuthenticationBackends.BACKENDS)
key = models.TextField(pgettext_lazy('Authentication field', 'key'))
password = models.TextField(
pgettext_lazy('Authentication field', 'password'))