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

Shouldn't do a unique check on auth.user.email #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3833815
removed unique email checking
Dec 13, 2010
f66b17d
Implemented removeAssociation since gmail sent just such a response.
Dec 13, 2010
58b6485
User friendly, helpful error if they enter an invalid OpenID.
Jan 7, 2011
47db2d4
xrds file so Yahoo won't complain about verifying your site.
Jan 10, 2011
0d996c9
added the return_to.xrds file
Jan 11, 2011
cf847a8
success on linking accounts page
Feb 18, 2011
074c9f6
going to /linkedin/ or another direct openid page without a login no …
Mar 2, 2011
b2de5bc
one of those shouldn't have been in the last commit.
Mar 2, 2011
033fc9a
redirect if someone cancels
Mar 3, 2011
b089980
the same openid for different users on different sites no longer blow…
Mar 3, 2011
0546b09
facebook canceling acts sane.
Mar 3, 2011
7eb4e78
do not cache when redirecting. thanks safari.
Mar 3, 2011
44398f7
better version.
Mar 3, 2011
565ca66
If you load /setup/ directly it now directs you on rather than blowin…
Mar 7, 2011
ad37f04
handling an obscure error
Apr 8, 2011
6c6d8a2
Occasional duplicate facebook profiles getting created caused login c…
May 25, 2011
926d0cf
Mail admins when encountering duplicate fb profiles
May 26, 2011
ace05b9
included a comment with a sql query for finding dupe facebook profiles.
May 26, 2011
8e89f5f
Django1.3 support: remove unused import CollectedObjects which does n…
schuyler1d Oct 13, 2011
8e67300
A twitter URL was depricated.
dasmith2 Feb 7, 2013
c0ed51b
Merge branch 'master' of github.com:dasmith2/django-socialregistration
dasmith2 Feb 7, 2013
220269a
capital d django
dasmith2 Feb 7, 2013
3906944
0.4.5 more defensive session variable cleaning on login.
dasmith2 Feb 20, 2013
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
.DS_Store
*.swp

django_socialregistration.egg-info
build/
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

METADATA = dict(
name='django-socialregistration',
version='0.4.2',
version='0.4.5',
author='Alen Mujezinovic',
author_email='[email protected]',
description='Django application enabling registration through a variety of APIs',
long_description=open('README.rst').read(),
url='http://github.com/flashingpumpkin/django-socialregistration',
keywords='django facebook twitter oauth openid registration',
install_requires=['django', 'oauth2', 'python-openid'],
install_requires=['Django', 'oauth2', 'python-openid'],
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
9 changes: 0 additions & 9 deletions socialregistration/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ def clean_username(self):
else:
raise forms.ValidationError(_('This username is already in use.'))

def clean_email(self):
email = self.cleaned_data.get('email')
try:
user = User.objects.get(email=email)
except User.DoesNotExist:
return email
else:
raise forms.ValidationError(_('This e-mailaddress is already in use.'))

def save(self):
self.user.username = self.cleaned_data.get('username')
self.user.email = self.cleaned_data.get('email')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h1>Provider Failure</h1>
<p>
It seems like your OpenID doesn't work. Here are some example
OpenIDs in case that helps clear things up.
</p>
<style type="text/css">
#examples { border-right: 1px solid #999; border-bottom: 1px solid #999 }
#examples td, #examples th {
border-left: 1px solid #999;
border-top: 1px solid #999;
padding: 5px }
#examples th { background-color: #ddd }
</style>
<table id="examples" cellspacing="0">
<tr>
<th>Provider</th>
<th>Example OpenID</th>
</tr>
<tr>
<td><a href="https://www.google.com/accounts">Google</a></td>
<td>https://www.google.com/accounts/o8/id</td>
</tr>
<tr>
<td><a href="http://openid.yahoo.com/">Yahoo!</a></td>
<td>me.yahoo.com</td>
</tr>
<tr>
<td><a href="https://www.myopenid.com/">MyOpenID</a></td>
<td><i>username</i>.myopenid.com</td>
</tr>
</table>
12 changes: 12 additions & 0 deletions socialregistration/templates/socialregistration/return_to.xrds
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
xmlns:xrds="xri://$xrds"
xmlns:openid="http://openid.net/xmlns/1.0"
xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="1">
<Type>http://specs.openid.net/auth/2.0/return_to</Type>
<URI>{{return_to}}</URI>
</Service>
</XRD>
</xrds:XRDS>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>
Congratulations! You have successfully linked your {{provider_login}} to
your {{site_name}} account with username {{username}}. This means you can log
in as {{username}} using your {{provider_login}}, so feel free to forget your
old {{username}} password. Your recommendations and comments will continue
to appear under {{username}}.
</p>

<p>
<a href="{{next}}">Continue to {{site_name}}</a>
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="X-XRDS-Location" content="{{url}}" />
6 changes: 6 additions & 0 deletions socialregistration/templatetags/openid_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""
from django import template

from socialregistration.utils import xrds_url

register = template.Library()

@register.inclusion_tag('socialregistration/openid_form.html', takes_context=True)
Expand All @@ -14,3 +16,7 @@ def openid_form(context):
logged_in = context['request'].user.is_authenticated()
next = context['next'] if 'next' in context else None
return dict(next=next, logged_in=logged_in)

@register.inclusion_tag('socialregistration/xrds_meta.html', takes_context=False)
def xrds_meta():
return dict(url=xrds_url())
3 changes: 2 additions & 1 deletion socialregistration/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@

urlpatterns = urlpatterns + patterns('',
url('^openid/redirect/', 'socialregistration.views.openid_redirect', name='openid_redirect'),
url('^openid/callback/', 'socialregistration.views.openid_callback', name='openid_callback')
url('^openid/callback/', 'socialregistration.views.openid_callback', name='openid_callback'),
url('^openid/return_to.xrds$', 'socialregistration.views.return_to', name='openid_return_to')
)
37 changes: 32 additions & 5 deletions socialregistration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def getAssociation(self, server_url, handle=None):

return assoc

def removeAssociation(self, server_url, handle):
OpenIDStoreModel.objects.filter(
server_url=server_url,
handle=handle
).delete()

def useNonce(self, server_url, timestamp, salt):
try:
nonce = OpenIDNonce.objects.get(
Expand Down Expand Up @@ -117,7 +123,14 @@ def __init__(self, request, return_to, endpoint):
self.result = None

def get_redirect(self):
auth_request = self.consumer.begin(self.endpoint)
try:
auth_request = self.consumer.begin(self.endpoint)
except AttributeError:
# On very rare occasions we get "AttributeError: 'NoneType' object
# has no attribute 'startswith'" deep in the bowels of the openid
# python module. Just redirect home in that case. It's probably
# something weird like a service goes down or a session expires.
return HttpResponseRedirect("/")
redirect_url = auth_request.redirectURL(
'http%s://%s/' % (_https(), Site.objects.get_current().domain),
self.return_to
Expand Down Expand Up @@ -263,15 +276,25 @@ def __init__(self, request, consumer_key, secret_key, request_token_url):

self.request_token_url = request_token_url

def get_access_token_or_none(self):
"""
Get the saved access token for private resources from the session.
Return None if there isn't one.
"""
return self.request.session.get(
'oauth_%s_access_token' % get_token_prefix(self.request_token_url),
None)

def _get_at_from_session(self):
"""
Get the saved access token for private resources from the session.
Raise an exception if there isn't one.
"""
try:
return self.request.session['oauth_%s_access_token' % get_token_prefix(self.request_token_url)]
except KeyError:
got = self.get_access_token_or_none()
if not got:
raise OAuthError(
_('No access token saved for "%s".') % get_token_prefix(self.request_token_url))
return got

def query(self, url, method="GET", params=dict(), headers=dict()):
"""
Expand Down Expand Up @@ -299,7 +322,7 @@ class OAuthTwitter(OAuth):
"""
Verifying twitter credentials
"""
url = 'https://twitter.com/account/verify_credentials.json'
url = 'https://api.twitter.com/1/account/verify_credentials.json'

def get_user_info(self):
user = simplejson.loads(self.query(self.url))
Expand All @@ -325,3 +348,7 @@ def get_user_info(self):

return user

def xrds_url():
return 'http%s://%s%s' % (_https(),
Site.objects.get_current().domain,
reverse('socialregistration.views.return_to'))
Loading