summaryrefslogtreecommitdiff
path: root/yaksh/pipeline
diff options
context:
space:
mode:
authorprathamesh2016-07-08 10:45:38 +0530
committerprathamesh2016-07-09 00:12:17 +0530
commit19f4c7b95bf32d0cf581274d947bdc9120c2e8f2 (patch)
treecc1efef7893be898e7e675a6073ba1e015b3b12c /yaksh/pipeline
parent41b4b7607d8ea6856a8b397d4c9e5bb9edea0b77 (diff)
downloadonline_test-19f4c7b95bf32d0cf581274d947bdc9120c2e8f2.tar.gz
online_test-19f4c7b95bf32d0cf581274d947bdc9120c2e8f2.tar.bz2
online_test-19f4c7b95bf32d0cf581274d947bdc9120c2e8f2.zip
oauth implemented
User can login via google and facebook. If user logs in from google and then later the same user logs in from facebook, then he will be considered as the same user if the email registered on facebook is of gmail. User profile will be created when user logs in via facebook or google. In yaksh pipeline, user.py is used to create profile. Pipeline settings is defined that defines the functions to be executed during oauth. Used bootstrap social and Font Awesome for UI design
Diffstat (limited to 'yaksh/pipeline')
-rw-r--r--yaksh/pipeline/__init__.py0
-rw-r--r--yaksh/pipeline/settings.py47
-rw-r--r--yaksh/pipeline/user.py8
3 files changed, 55 insertions, 0 deletions
diff --git a/yaksh/pipeline/__init__.py b/yaksh/pipeline/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/yaksh/pipeline/__init__.py
diff --git a/yaksh/pipeline/settings.py b/yaksh/pipeline/settings.py
new file mode 100644
index 0000000..60d706e
--- /dev/null
+++ b/yaksh/pipeline/settings.py
@@ -0,0 +1,47 @@
+AUTH_PIPELINE = (
+ # Get the information we can about the user and return it in a simple
+ # format to create the user instance later. On some cases the details are
+ # already part of the auth response from the provider, but sometimes this
+ # could hit a provider API.
+ 'social.pipeline.social_auth.social_details',
+
+ # Get the social uid from whichever service we're authing thru. The uid is
+ # the unique identifier of the given user in the provider.
+ 'social.pipeline.social_auth.social_uid',
+
+ # Verifies that the current auth process is valid within the current
+ # project, this is where emails and domains whitelists are applied (if
+ # defined).
+ 'social.pipeline.social_auth.auth_allowed',
+
+ # Checks if the current social-account is already associated in the site.
+ 'social.pipeline.social_auth.social_user',
+
+ # Make up a username for this person, appends a random string at the end if
+ # there's any collision.
+ 'social.pipeline.user.get_username',
+
+ # Send a validation email to the user to verify its email address.
+ # Disabled by default.
+ # 'social.pipeline.mail.mail_validation',
+
+ # Associates the current social details with another user account with
+ # a similar email address. Disabled by default.
+ 'social.pipeline.social_auth.associate_by_email',
+
+ # Create a user account if we haven't found one yet.
+ 'social.pipeline.user.create_user',
+
+ # Create a profile if profile does not exist
+ 'yaksh.pipeline.user.save_profile',
+
+ # Create the record that associated the social account with this user.
+ 'social.pipeline.social_auth.associate_user',
+
+ # Populate the extra_data field in the social record with the values
+ # specified by settings (and the default ones like access_token, etc).
+ 'social.pipeline.social_auth.load_extra_data',
+
+ # Update the user record with any changed info from the auth service.
+ 'social.pipeline.user.user_details',
+)
diff --git a/yaksh/pipeline/user.py b/yaksh/pipeline/user.py
new file mode 100644
index 0000000..4aecd95
--- /dev/null
+++ b/yaksh/pipeline/user.py
@@ -0,0 +1,8 @@
+from yaksh.models import Profile
+#from django.contrib.auth.models import User
+
+def save_profile(backend, user, response, *args, **kwargs):
+ if not hasattr(user, 'profile'):
+ profile = Profile.objects.create(user=user)
+ profile.roll_number = profile.id
+ profile.save()