Skip to content

Instantly share code, notes, and snippets.

@dchaplinsky
Created September 16, 2011 22:30
Show Gist options
  • Select an option

  • Save dchaplinsky/1223313 to your computer and use it in GitHub Desktop.

Select an option

Save dchaplinsky/1223313 to your computer and use it in GitHub Desktop.
social auth
SOCIAL_DETAILS = None
def soul_catcher(sender, uid, response, details, **kwargs):
global SOCIAL_DETAILS
SOCIAL_DETAILS = details
socialauth_not_registered.connect(soul_catcher, sender=None)
@render_to("account/signup.html")
def register(request, backend):
"""Start authentication process"""
code = request.GET.get("code")
signup_code = check_signup_code(code)
if signup_code:
request.session['signup_code'] = signup_code
return auth(request, backend)
else:
return ({
"code": code,
},
"signup_codes/failure.html"
)
def complete(request, backend):
"""Authentication complete view, override this view if transaction
management doesn't suit your needs."""
global SOCIAL_DETAILS
SOCIAL_DETAILS = None
signup_code = check_signup_code(request.session.get('signup_code', ''))
if signup_code:
del request.session['signup_code']
result = simple_complete(request, backend)
if request.user.is_authenticated():
signup_code.use(request.user)
return result
else:
result = simple_complete(request, backend, create_user=False)
print(SOCIAL_DETAILS)
# Some black magic with social details below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment