Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social auth #99

Merged
merged 3 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jumbocashapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create_superuser(self, email, password, **kwargs):
class Retailer(AbstractBaseUser, PermissionsMixin):
""" Model for Retailer users """
email = models.EmailField(max_length=255, unique=True)
mobile_no = models.CharField(max_length=10, unique=True)
mobile_no = models.CharField(max_length=10, blank=True)
firstname = models.CharField(max_length=255)
lastname = models.CharField(max_length=255, blank=True)
business_name = models.CharField(max_length=255, blank=True)
Expand Down
1 change: 1 addition & 0 deletions jumbocashapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
path('register', views.RetailerCreateView.as_view()),
path('login/', obtain_auth_token)


]
47 changes: 46 additions & 1 deletion jumbocashbackend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,27 @@
'rest_framework.authtoken',
'multiple_permissions',
'django_filters',
'django.contrib.sites',
#apps
'corsheaders',
'jumbocashapi',

#all auth

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
]


AUTHENTICATION_BACKENDS = [

# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',

# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
]


Expand Down Expand Up @@ -180,5 +198,32 @@
CORS_ORIGIN_ALLOW_ALL = True # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect
CORS_ALLOW_CREDENTIALS = True


SITE_ID = 2

# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
'google': {
# For each OAuth based provider, either add a ``SocialApp``
# (``socialaccount`` app) containing the required client
# credentials, or list them here:
'APP': {
'client_id': '868441464956-tokq3gth8g2h25oqi34fuabpan1f5u6l.apps.googleusercontent.com',
'secret': 'fnJJNF7BLSpYi3LI6qDRbI9p',
'key': ''
}
}
}

# Allauth settings
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
LOGIN_REDIRECT_URL = '/retailers/profile/'
ACCOUNT_LOGOUT_REDIRECT_URL ='/accounts/login/'

#for heroku
django_heroku.settings(locals())
django_heroku.settings(locals())

4 changes: 3 additions & 1 deletion jumbocashbackend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('jumbocashapi.urls'))
path('', include('jumbocashapi.urls')),
path('accounts/', include('allauth.urls')),

]