Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Reorganize authentication backends
Mira Szewczykabc08f8fb40c
diff --git a/saleor/registration/backends/facebook.py b/saleor/registration/backends/facebook.pyindex 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 FacebookOAuth2from . import BaseBackend-from ...site.models import FACEBOOK+from ...site import AuthenticationBackendsclass CustomFacebookOAuth2(BaseBackend, FacebookOAuth2):- DB_NAME = FACEBOOK+ DB_NAME = AuthenticationBackends.FACEBOOKdiff --git a/saleor/registration/backends/google.py b/saleor/registration/backends/google.pyindex 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 GoogleOAuth2from . import BaseBackend-from ...site.models import GOOGLE+from ...site import AuthenticationBackendsclass CustomGoogleOAuth2(BaseBackend, GoogleOAuth2):- DB_NAME = GOOGLE+ DB_NAME = AuthenticationBackends.GOOGLEdiff --git a/saleor/site/__init__.py b/saleor/site/__init__.pyindex 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.pyindex d75b5b9bb4..405d4256e1 100644--- a/saleor/site/models.py+++ b/saleor/site/models.py@@ -3,11 +3,7 @@ from django.db import modelsfrom django.utils.encoding import python_2_unicode_compatiblefrom 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'))