예제 #1
0
def default_on_success(request, identity_url, openid_response):
    username = str(request.GET['openid.claimed_id'][36:])
    user, new = User.objects.get_or_create(username=username)
    if new:
        user.set_password('!')
        user.save()
    user = authenticate(username=user.username, password='******')
    if user is not None:
        if user.is_active:
            login(request, user)

    if 'openids' not in request.session.keys():
        request.session['openids'] = []

    # Eliminate any duplicates
    request.session['openids'] = [
        o for o in request.session['openids'] if o.openid != identity_url
    ]
    request.session['openids'].append(from_openid_response(openid_response))

    # Set up request.openids and request.openid, reusing middleware logic
    OpenIDMiddleware().process_request(request)

    next = request.GET.get('next', '').strip()
    if not next or not is_valid_next_url(request, next):
        next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')

    return HttpResponseRedirect(next)
예제 #2
0
def default_on_success(request,
                       identity_url,
                       openid_response,
                       confirmed=True,
                       email=""):
    if 'openids' not in request.session.keys():
        request.session['openids'] = []

    # Eliminate any duplicates
    request.session['openids'] = [
        o for o in request.session['openids'] if o.openid != identity_url
    ]
    request.session['openids'].append(from_openid_response(openid_response))

    # Set up request.openids and request.openid, reusing middleware logic
    OpenIDMiddleware().process_request(request)

    next = request.GET.get('next', '').strip()

    if confirmed:
        redirect_next = 'OPENID_REDIRECT_NEXT'
    else:
        redirect_next = 'OPENID_REDIRECT_CONFIRM_NEXT'
    if not next or not is_valid_next_url(next):
        next = getattr(settings, redirect_next, '/')
        if email:
            next += ("?email=%s" % (email))
    else:
        next = "%s?next=%s&email=%s" % (getattr(settings, redirect_next,
                                                '/'), next, email)
    return HttpResponseRedirect(next)
예제 #3
0
def default_on_success(request, identity_url, openid_response):
    if 'openids' not in request.session.keys():
        request.session['openids'] = []
    
    # Eliminate any duplicates
    request.session['openids'] = [
        o for o in request.session['openids'] if o.openid != identity_url
    ]
    request.session['openids'].append(from_openid_response(openid_response))
    
    # Set up request.openids and request.openid, reusing middleware logic
    OpenIDMiddleware().process_request(request)
    
    next = request.GET.get('next', '').strip()
    if not next or not is_valid_next_url(next):
        next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
    
    return HttpResponseRedirect(next)