Skip to content

Commit

Permalink
Merge pull request #99 from Crio-Winter-of-Doing-2021/social-auth
Browse files Browse the repository at this point in the history
Social auth
  • Loading branch information
sukanta-nandi authored Apr 5, 2021
2 parents 8c25a6d + e15fbef commit e1e0b88
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
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')),

]

0 comments on commit e1e0b88

Please sign in to comment.