diff --git a/requirements.txt b/requirements.txt
index 4e367d7..e720a62 100644
Binary files a/requirements.txt and b/requirements.txt differ
diff --git a/vms/authentication/templates/authentication/login.html b/vms/authentication/templates/authentication/login.html
index 7d7512c..90c3be5 100644
--- a/vms/authentication/templates/authentication/login.html
+++ b/vms/authentication/templates/authentication/login.html
@@ -71,5 +71,8 @@
+
+ Sign in with Github
+
{% endblock %}
diff --git a/vms/authentication/views.py b/vms/authentication/views.py
index 679c5ae..d969a4e 100644
--- a/vms/authentication/views.py
+++ b/vms/authentication/views.py
@@ -1,10 +1,14 @@
# Django
from django.urls import reverse
from django.shortcuts import redirect
+from social_django.models import UserSocialAuth
+from django.shortcuts import render
# local Django
from vms import settings
-
+from registration.views import VolunteerSignupView
+from registration.forms import UserForm
+from volunteer.forms import VolunteerForm
def index(request):
return redirect(reverse('authentication:login_process'))
@@ -24,3 +28,18 @@ def as_view(request, *args, **kwargs):
return as_view
+def github_auth_dialog_step(strategy, backend, request, details, *args, **kwargs):
+ print(details)
+ # print(kwargs)
+ user_form = UserForm(prefix='usr')
+ volunteer_form = VolunteerForm(prefix="vol")
+
+ # print(volunteer_form)
+
+ return render(
+ request, 'registration/signup_volunteer.html', {
+ 'user_form' : user_form,
+ 'username': details["username"],
+ 'volunteer_form': volunteer_form,
+ })
+
diff --git a/vms/vms/settings.py b/vms/vms/settings.py
index 8af695e..64e052c 100644
--- a/vms/vms/settings.py
+++ b/vms/vms/settings.py
@@ -29,6 +29,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'social_django',
'administrator',
'event',
'home',
@@ -58,6 +59,29 @@
WSGI_APPLICATION = 'vms.wsgi.application'
+# Social Authentication
+AUTHENTICATION_BACKENDS = (
+ 'social_core.backends.github.GithubOAuth2',
+ 'django.contrib.auth.backends.ModelBackend',
+)
+
+SOCIAL_AUTH_GITHUB_KEY = config('GITHUB_KEY')
+SOCIAL_AUTH_GITHUB_SECRET = config('GITHUB_SECRET')
+
+# User details from social profiles.
+SOCIAL_AUTH_PIPELINE = (
+ 'social_core.pipeline.social_auth.social_details',
+ 'social_core.pipeline.social_auth.social_uid',
+ 'social_core.pipeline.social_auth.social_user',
+ 'social_core.pipeline.user.get_username',
+ 'social_core.pipeline.social_auth.associate_by_email',
+ 'social_core.pipeline.user.create_user',
+ 'social_core.pipeline.social_auth.associate_user',
+ 'social_core.pipeline.social_auth.load_extra_data',
+ 'social_core.pipeline.user.user_details',
+ 'authentication.views.github_auth_dialog_step',
+)
+
# Database
# Change these database settings if your database engine, database name,
# username or password changes
@@ -71,6 +95,8 @@
}
}
+# This must be set to true for social auth in postgres.
+SOCIAL_AUTH_POSTGRES_JSONFIELD = True
TEMPLATES = [
{
@@ -83,6 +109,8 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
+ 'social_django.context_processors.backends',
+ 'social_django.context_processors.login_redirect',
],
},
},
diff --git a/vms/vms/urls.py b/vms/vms/urls.py
index 9f75f16..2d8148e 100644
--- a/vms/vms/urls.py
+++ b/vms/vms/urls.py
@@ -24,6 +24,7 @@
include('registration.urls', namespace='registration')),
url(r'^shift/', include('shift.urls', namespace='shift')),
url(r'^volunteer/', include('volunteer.urls', namespace='volunteer')),
+ url(r'^social-auth/', include('social_django.urls', namespace='social')),
)
if settings.DEBUG: