示例#1
0
def add_email(request, form):
    result = request.session.get('token')
    if result:
        uid, provider, defaults = parse_result(result)
        defaults['email'] = form.cleaned_data['email']

        if Profile.objects.filter(email=defaults['email']).exists():
            return HttpResponse(simplejson.dumps({'response':
                            {'email':_('User with this email already exists')}, 'result': 'error'}))

        del request.session['token']
        user = register_loginza_user(uid, provider, defaults, request)
        return HttpResponse(simplejson.dumps({'response': user.get_register_redirect(), 'result': 'success'}))
    raise Http404
示例#2
0
def loginza_login(request):
    if request.method=='POST':
        token=request.POST.get('token')
        if token:
            result = simplejson.loads(get_auth_info(token))
            # Check if there is an error - like token was used previously
            if result.has_key('error_message'):
                # TODO: redirect to page with error message and ask for relogin
                send_email.delay('mail/error', {'message': str(result)}, "Loginza Error")
                raise Http404
            uid, provider, defaults = parse_result(result)
            if not (defaults['email'] or Profile.objects.filter(uid=uid, provider=provider).exists()):
                form = RequestEmailForm(request=request)
                request.session['token'] = result
                return direct_to_template(request, "users/request_email.html", extra_context={'form': form })
            user = register_loginza_user(uid, provider, defaults, request)
            return HttpResponseRedirect(user.get_register_redirect())
    raise Http404
示例#3
0
def loginza_login(request):
    if request.method == 'POST':
        token = request.POST.get('token')
        if token:
            result = simplejson.loads(get_auth_info(token))
            # Check if there is an error - like token was used previously
            if result.has_key('error_message'):
                # TODO: redirect to page with error message and ask for relogin
                send_email.delay('mail/error', {'message': str(result)},
                                 "Loginza Error")
                raise Http404
            uid, provider, defaults = parse_result(result)
            if not (defaults['email'] or Profile.objects.filter(
                    uid=uid, provider=provider).exists()):
                form = RequestEmailForm(request=request)
                request.session['token'] = result
                return direct_to_template(request,
                                          "users/request_email.html",
                                          extra_context={'form': form})
            user = register_loginza_user(uid, provider, defaults, request)
            return HttpResponseRedirect(user.get_register_redirect())
    raise Http404
示例#4
0
def add_email(request, form):
    result = request.session.get('token')
    if result:
        uid, provider, defaults = parse_result(result)
        defaults['email'] = form.cleaned_data['email']

        if Profile.objects.filter(email=defaults['email']).exists():
            return HttpResponse(
                simplejson.dumps({
                    'response': {
                        'email': _('User with this email already exists')
                    },
                    'result': 'error'
                }))

        del request.session['token']
        user = register_loginza_user(uid, provider, defaults, request)
        return HttpResponse(
            simplejson.dumps({
                'response': user.get_register_redirect(),
                'result': 'success'
            }))
    raise Http404