Skip to content
Browse files

More backwards compatibility

  • Loading branch information...
1 parent 1dec6c5 commit 53b848b6501e7ee11b7fb917341462e135d4872e @flashingpumpkin flashingpumpkin committed
View
3 example/settings.py
@@ -177,7 +177,7 @@
# Add your Facebook API keys here
FACEBOOK_APP_ID = ''
FACEBOOK_SECRET_KEY = ''
-FACEBOOK_REQUEST_PERMISSIONS = 'email,user_about_me'
+FACEBOOK_REQUEST_PERMISSIONS = ''
# Add your Twitter API keys here
TWITTER_CONSUMER_KEY = ''
@@ -190,6 +190,7 @@
# Add your Github API keys here
GITHUB_CLIENT_ID = ''
GITHUB_SECRET = ''
+GITHUB_REQUEST_PERMISSIONS = ''
SOCIALREGISTRATION_USE_HTTPS = False
View
12 socialregistration/auth.py
@@ -1,10 +1,6 @@
from django.contrib.auth.models import User
+from socialregistration.contrib.facebook.auth import FacebookAuth
+from socialregistration.contrib.linkedin.auth import LinkedInAuth
+from socialregistration.contrib.openid.auth import OpenIDAuth
+from socialregistration.contrib.twitter.auth import TwitterAuth
-class Auth(object):
- supports_object_permissions = False
- supports_anonymous_user = False
- def get_user(self, user_id):
- try:
- return User.objects.get(pk=user_id)
- except User.DoesNotExist:
- return None
View
5 socialregistration/clients/oauth.py
@@ -116,6 +116,7 @@ class OAuth2(Client):
auth_url = None
access_token_url = None
+ scope = None
_access_token = None
@@ -125,12 +126,12 @@ def __init__(self, access_token = None):
def client(self):
return httplib2.Http()
- def get_redirect_url(self, scope = '', state = ''):
+ def get_redirect_url(self,state = ''):
params = {
'response_type': 'code',
'client_id': self.client_id,
'redirect_uri': self.get_callback_url(),
- 'scope': scope,
+ 'scope': self.scope or '',
'state': state,
}
View
7 socialregistration/contrib/facebook/auth.py
@@ -1,9 +1,12 @@
+from django.contrib.auth.backends import ModelBackend
from django.contrib.sites.models import Site
-from socialregistration.auth import Auth
from socialregistration.contrib.facebook.models import FacebookProfile
-class FacebookAuth(Auth):
+class FacebookAuth(ModelBackend):
+ supports_object_permissions = False
+ supports_anonymous_user = False
+
def authenticate(self, uid = None):
try:
return FacebookProfile.objects.get(
View
3 socialregistration/contrib/facebook/client.py
@@ -8,10 +8,13 @@
class Facebook(OAuth2):
client_id = getattr(settings, 'FACEBOOK_APP_ID', '')
secret = getattr(settings, 'FACEBOOK_SECRET_KEY', '')
+ scope = getattr(settings, 'FACEBOOK_REQUEST_PERMISSIONS', '')
auth_url = 'https://www.facebook.com/dialog/oauth'
access_token_url = 'https://graph.facebook.com/oauth/access_token'
+
+
graph = None
_user_info = None
View
5 socialregistration/contrib/github/auth.py
@@ -1,8 +1,9 @@
from django.contrib.sites.models import Site
-from socialregistration.auth import Auth
from socialregistration.contrib.github.models import GithubProfile
+from django.contrib.auth.backends import ModelBackend
-class GithubAuth(Auth):
+
+class GithubAuth(ModelBackend):
def authenticate(self, github = None):
try:
return GithubProfile.objects.get(
View
1 socialregistration/contrib/github/client.py
@@ -8,6 +8,7 @@
class Github(OAuth2):
client_id = getattr(settings, 'GITHUB_CLIENT_ID', '')
secret = getattr(settings, 'GITHUB_SECRET', '')
+ scope = getattr(settings, 'GITHUB_REQUEST_PERMISSIONS', '')
auth_url = 'https://github.com/login/oauth/authorize'
access_token_url = 'https://github.com/login/oauth/access_token'
View
7 socialregistration/contrib/linkedin/auth.py
@@ -1,9 +1,12 @@
+from django.contrib.auth.backends import ModelBackend
from django.contrib.sites.models import Site
-from socialregistration.auth import Auth
from socialregistration.contrib.linkedin.models import LinkedInProfile
-class LinkedInAuth(Auth):
+class LinkedInAuth(ModelBackend):
+ supports_object_permissions = False
+ supports_anonymous_user = False
+
def authenticate(self, linkedin_id=None):
try:
return LinkedInProfile.objects.get(
View
6 socialregistration/contrib/openid/auth.py
@@ -1,10 +1,10 @@
-from socialregistration.auth import Auth
+from django.contrib.auth.backends import ModelBackend
from django.contrib.sites.models import Site
+from socialregistration.contrib.openid.models import OpenIDProfile
-from socialregistration.contrib.openid.models import OpenIDProfile
-class OpenIDAuth(Auth):
+class OpenIDAuth(ModelBackend):
def authenticate(self, identity=None):
try:
return OpenIDProfile.objects.get(
View
5 socialregistration/contrib/twitter/auth.py
@@ -1,9 +1,10 @@
+from django.contrib.auth.backends import ModelBackend
from django.contrib.sites.models import Site
-from socialregistration.auth import Auth
from socialregistration.contrib.twitter.models import TwitterProfile
-class TwitterAuth(Auth):
+class TwitterAuth(ModelBackend):
+
def authenticate(self, twitter_id=None):
try:
return TwitterProfile.objects.get(
View
4 socialregistration/utils.py
@@ -0,0 +1,4 @@
+import uuid
+
+def generate_username(user, profile, client):
+ return str(uuid.uuid4())[:30]
View
2 socialregistration/views.py
@@ -67,7 +67,7 @@ def get(self, request):
error=_("A social profile is missing from your session.")))
if GENERATE_USERNAME:
- return self.generate_username_and_redirect(user, profile, client)
+ return self.generate_username_and_redirect(request, user, profile, client)
form = self.get_form()(initial=self.get_initial_data(request, user, profile, client))

0 comments on commit 53b848b

Please sign in to comment.
Something went wrong with that request. Please try again.