Exemple #1
0
def register(request):
    if request.method == 'POST':
        form = ClassicRegisterForm(request.POST.copy())
        #form = ClassicRegisterForm(request.POST)
        logging.info(form)
        if form.is_valid():
            logging.error(form.cleaned_data)
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            #email = form.cleaned_data['email']

            #user_ = User(username=username, email=email)
            user_ = User(username=username)
            user_.set_password(password)

            if User.objects.all().count() == 0:
                user_.is_superuser = True
                user_.is_staff = True

            user_.save()
            #UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()

            return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
    else:
        #form = ClassicRegisterForm(initial={'next':'/'})
        form = ClassicRegisterForm()

    return render_to_response('auth/complete.html', {
        'form1': form
        }, context_instance=RequestContext(request))
def register(request):
    if request.method == 'POST':
        form = ClassicRegisterForm(request.POST)

        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            email = form.cleaned_data['email']

            user_ = User(username=username, email=email)
            user_.set_password(password)

            if User.objects.all().count() == 0:
                user_.is_superuser = True
                user_.is_staff = True

            user_.save()
            UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()

            return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
    else:
        form = ClassicRegisterForm(initial={'next':reverse('index')})

    return render_to_response('auth/complete.html', {
        'form1': form
        }, context_instance=RequestContext(request))
Exemple #3
0
def register(request):
    if request.method == 'POST':
        form = ClassicRegisterForm(request.POST)
        email_feeds_form = SimpleEmailSubscribeForm(request.POST)

        if form.is_valid() and email_feeds_form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            email = form.cleaned_data['email']

            user_ = User(username=username, email=email)
            user_.set_password(password)

            if User.objects.all().count() == 0:
                user_.is_superuser = True
                user_.is_staff = True

            user_.save()
            UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()

            if email_feeds_form.cleaned_data['subscribe'] == 'n':
                user_.subscription_settings.enable_notifications = False
                user_.subscription_settings.save()

            return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
    else:
        form = ClassicRegisterForm(initial={'next':'/'})
        email_feeds_form = SimpleEmailSubscribeForm()

    return render_to_response('auth/complete.html', {
        'form1': form,
        'email_feeds_form': email_feeds_form
        }, context_instance=RequestContext(request))
Exemple #4
0
def register(request):
    if request.method == "POST":
        form = ClassicRegisterForm(request.POST)
        email_feeds_form = SimpleEmailSubscribeForm(request.POST)

        if form.is_valid() and email_feeds_form.is_valid():
            username = form.cleaned_data["username"]
            password = form.cleaned_data["password1"]
            email = form.cleaned_data["email"]

            user_ = User(username=username, email=email)
            user_.set_password(password)

            if User.objects.all().count() == 0:
                user_.is_superuser = True
                user_.is_staff = True

            user_.save()

            UserJoinsAction(user=user_, ip=request.META["REMOTE_ADDR"]).save()

            if email_feeds_form.cleaned_data["subscribe"] == "n":
                user_.subscription_settings.enable_notifications = False
                user_.subscription_settings.save()

            return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
    else:
        form = ClassicRegisterForm(initial={"next": "/"})
        email_feeds_form = SimpleEmailSubscribeForm()

    return render_to_response(
        "auth/complete.html",
        {"form1": form, "email_feeds_form": email_feeds_form},
        context_instance=RequestContext(request),
    )
Exemple #5
0
def register(request):
    banned_ips = cache.get(BANNED_IPS_KEY, set())
    ip = get_client_ip(request)
    if ip in banned_ips:
        logging.warning("Spammer returned ip:%s" % ip)
        return HttpResponseRedirect("http://www.pudelek.pl/artykul/x/")

    if request.method == "POST":
        banned_emails = cache.get(BANNED_EMAILS_KEY, set())
        if request.POST["email"] in banned_emails:
            logging.warning("Spammer returned:%s, ip:%s" % (request.POST["email"], ip))
            return HttpResponseRedirect("http://www.pudelek.pl/artykul/x/")

        form = ClassicRegisterForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data["username"]
            password = form.cleaned_data["password1"]
            email = form.cleaned_data["email"]

            # Honeypot checks
            if request.POST.get("age", None):
                logging.warning("Age honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
                ban(email, ip)
                return HttpResponseRedirect(reverse("index"))

            if request.POST.get("birthday", None):
                logging.warning("Birthday honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
                ban(email, ip)
                return HttpResponseRedirect(reverse("index"))

            if request.POST.get("website", None):
                logging.warning("Website honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
                ban(email, ip)
                return HttpResponseRedirect(reverse("index"))

            user_ = User(username=username, email=email)
            user_.set_password(password)

            if User.objects.all().count() == 0:
                user_.is_superuser = True
                user_.is_staff = True

            user_.save()
            UserJoinsAction(user=user_, ip=request.META["REMOTE_ADDR"]).save()
            logging.info("New user joined with email:%s from ip:%s" % (email, ip))

            return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
    else:
        form = ClassicRegisterForm(initial={"next": "/"})

    return render_to_response(
        "auth/register.html",
        {"form1": form, "bigicon_providers": _get_bigicon_providers(request)},
        context_instance=RequestContext(request),
    )
Exemple #6
0
def register(request):
    if request.method == 'POST':
        form = ClassicRegisterForm(request.POST)
        email_feeds_form = SimpleEmailSubscribeForm(request.POST)

        if form.is_valid() and email_feeds_form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            email = form.cleaned_data['email']

            user_ = User.objects.create_user( username,email,password )
            send_validation_email(user_)
            email_feeds_form.save(user_)
            return login_and_forward(request, user_, None, _("A validation email has been sent to your email address. "))
    else:
        form = ClassicRegisterForm(initial={'next':'/'})
        email_feeds_form = SimpleEmailSubscribeForm()

    return render_to_response('auth/signup.html', {
        'form': form,
        'email_feeds_form': email_feeds_form
        }, context_instance=RequestContext(request))