Skip to content

Instantly share code, notes, and snippets.

@dchaplinsky
Created March 15, 2011 16:55
Show Gist options
  • Select an option

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

Select an option

Save dchaplinsky/871026 to your computer and use it in GitHub Desktop.
To make it possible to only register users who provided invite code and log in only users which was already registered
@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."""
signup_code = check_signup_code(request.session.get('signup_code', ''))
if signup_code:
del request.session['signup_code']
return simple_complete(request, backend)
else:
create_users = getattr(settings, 'SOCIAL_AUTH_CREATE_USERS', True)
settings.SOCIAL_AUTH_CREATE_USERS = False
result = simple_complete(request, backend)
settings.SOCIAL_AUTH_CREATE_USERS = create_users
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment