Exemple #1
0
def validate_registration(request):
    """validate registration data"""
    # step1 - email and password and captcha
    if email_errors(request):
        return email_errors(request, return_values = 3)

    # Password is generated by us

    # Captcha
    if not (settings.DEBUG and request.POST.get("ignorecaptcha", False)):
        if not captcha_valid(request, "register"):
            return (__('Captcha'), '1', __('Captcha challenge failed'))
        invalidate_captcha(request, "register")

    # step2 - languages
    if language_errors(request):
        return language_errors(request, return_values = 3)

    # step3 - location
    if location_errors(request):
        return location_errors(request, return_values = 3)

    # step4 - about me
    if contactinfo_errors(request):
        return contactinfo_errors(request, return_values = 3)
    if aboutme_errors(request):
        return aboutme_errors(request, return_values = 3)

    return (None, None, None)
Exemple #2
0
def get_new_captcha(request):
    """get new captcha image"""
    if not valid_token(request):
        return token_splash_page(request)

    invalidate_captcha(request)
    form = CaptchaTestForm()
    new_form = ""
    for field in form:
        new_form += str(field)
    return HttpResponse (new_form)
Exemple #3
0
def validate_captcha(request):
    """validate captcha"""
    if not valid_token(request):
        return token_splash_page(request)
  
    # extract captcha data from request
    test = deepcopy(request.POST)
    cid = request.GET.get("captchaid", "")
    ctext = request.GET.get("captchatext", "")
    test.__setitem__('captcha_0', cid)
    test.__setitem__('captcha_1', ctext)

    captcha_form = CaptchaTestForm (test)
    
    if not captcha_form.is_valid():
        invalidate_captcha(request)
        return HttpResponse("fail")
    else:
        save_valid_captcha(request)
        return HttpResponse("win")