Ejemplo n.º 1
0
def login(request, template="accounts/account_login.html"):
    """
    Login form.
    """
    isAjax = False
    form = LoginForm(request.POST or None)
    next = get_login_redirect_url(request)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        #info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        if request.is_ajax():
            if  request.user.is_authenticated():
                return HttpResponse(simplejson.dumps(dict(url=next,
                                                          success=True)))
            else:
                return HttpResponse(simplejson.dumps(dict(success=False)))                
        else:
            return login_redirect(request)
    elif form.errors:
        return HttpResponse(simplejson.dumps(dict(errors=form.errors, success=False)))

    if request.is_ajax():
        template = "accounts/ajax_account_login.html"

    context = {"form": form, "title": _("Log in"), "next":next}
    return render(request, template, context)
Ejemplo n.º 2
0
def signup(request, template="accounts/account_signup.html",
           extra_context=None):
    """
    Signup form.
    """
    #Staat in admin_forms
    form = NewUserCreationForm(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(request, _("Thanks for signing up! You'll receive "
                                "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(request, _("A verification email has been sent with "
                                "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    context.update(extra_context or {})
    return render(request, template, context)
Ejemplo n.º 3
0
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(request, _("Thanks for signing up! You'll receive "
                                "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(request, _("A verification email has been sent with "
                                "a link for activating your account."))
            return redirect(request.GET.get("next", "/"))
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    else:
        log.debug('Form is not valid. Errors: %s' % form.errors)
    context = {"form": form, "title": _("Create an Account"), "submit_label": "Next Step"}
    return render(request, template, context)
Ejemplo n.º 4
0
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = UserRegistrationLeadForm
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        data = form.cleaned_data.copy()

        # ensure user is not a robot
        honeypot = data.pop('superpriority')
        if honeypot:
            raise PermissionDenied

        # save the user
        new_user = form.save()

        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(request, _("Thanks for signing up! You'll receive "
                                "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(request, _("A verification email has been sent with "
                                "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    return render(request, template, context)
Ejemplo n.º 5
0
def signup(request,
           template="accounts/account_signup.html",
           extra_context=None):
    """
    Signup form.
    """
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(
                    request,
                    _("Thanks for signing up! You'll receive "
                      "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(
                    request,
                    _("A verification email has been sent with "
                      "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
Ejemplo n.º 6
0
def signup_verify(request, uidb36=None, token=None):
    """
    View for the link in the verification email sent to a new user
    when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
    is set to ``True``. Activates the user and logs them in,
    redirecting to the URL they tried to access when signing up.
    """
    user = authenticate(uidb36=uidb36, token=token, is_active=False)
    if user is not None:
        user.is_active = True
        user.save()
        auth_login(request, user)
        info(request, _("Successfully signed up"))
        email = user.email
        sitio = email.split("@")[1]
        if sitio == "urjc.es":
            try:
                g = Group.objects.get(name='profesores')
            except:
                g = Group.objects.create(name="profesores")
            g.user_set.add(user)
        else:
            try:
                g = Group.objects.get(name='alumnos')
            except:
                g = Group.objects.create(name="alumnos")
            g.user_set.add(user)
        return login_redirect(request)
    else:
        error(request, _("The link you clicked is no longer valid."))
        return redirect("/")
Ejemplo n.º 7
0
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(
                    request,
                    _("Thanks for signing up! You'll receive "
                      "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(
                    request,
                    _("A verification email has been sent with "
                      "a link for activating your account."))
            return redirect(request.GET.get("next", "/"))
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    else:
        log.debug('Form is not valid. Errors: %s' % form.errors)
    context = {
        "form": form,
        "title": _("Create an Account"),
        "submit_label": "Next Step"
    }
    return render(request, template, context)
Ejemplo n.º 8
0
def register_user(request):
    print("registrando um novo usuário")
    profile_form = get_profile_form()
    form = profile_form(request.POST or None, request.FILES or None)
    print(form)
    print(dir(form))
    print(form.is_valid())
    if request.method == "POST" and form.is_valid():
        print("Método post e form válido")
        new_user = form.save()
        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                print('Usuário cadastrado, aguardando aprovação')
                send_approve_mail(request, new_user)
                info(
                    request, "Obrigado por se cadastrar! Você receberá um "
                    "email quando sua conta for ativada.")
            else:
                print('Usuário cadastrado, aguardando confirmação')
                send_verification_mail(request, new_user, "signup_verify")
                info(
                    request, "Um email de verificação foi enviado com um "
                    "link para ativação de sua conta.")
            return redirect(next_url(request) or "/")
        else:
            print('usuário cadastrado com sucesso')
            info(request, "Cadastro realizado com sucesso")
            login(request, new_user)
            return login_redirect(request)
    else:
        error(request, form)
        return redirect(request.META['HTTP_REFERER'] + "#cadastro",
                        kwargs={'registration_form': form})
    return redirect(next_url(request) or request.META['HTTP_REFERER'])
Ejemplo n.º 9
0
def signup(request,
           template="accounts/account_signup.html",
           extra_context=None):
    """
    Signup form. Overriding mezzanine's view function for signup submit
    """
    form = SignupForm(request, request.POST, request.FILES)
    if request.method == "POST" and form.is_valid():
        try:
            new_user = form.save()
        except ValidationError as e:
            messages.error(request, e.message)
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
        else:
            if not new_user.is_active:
                if settings.ACCOUNTS_APPROVAL_REQUIRED:
                    send_approve_mail(request, new_user)
                    info(
                        request,
                        _("Thanks for signing up! You'll receive "
                          "an email when your account is activated."))
                else:
                    send_verification_mail(request, new_user, "signup_verify")
                    info(
                        request,
                        _("A verification email has been sent to " +
                          new_user.email +
                          " with a link that must be clicked prior to your account "
                          "being activated. If you do not receive this email please "
                          "check that you entered your address correctly, or your "
                          "spam folder as sometimes the email gets flagged as spam. "
                          "If you entered an incorrect email address, please request "
                          "an account again."))
                return redirect(next_url(request) or "/")
            else:
                info(request, _("Successfully signed up"))
                auth_login(request, new_user)
                return login_redirect(request)

    # remove the key 'response' from errors as the user would have no idea what it means
    form.errors.pop('response', None)
    messages.error(request, form.errors)

    # TODO: User entered data could be retained only if the following
    # render function would work without messing up the css

    # context = {
    #     "form": form,
    #     "title": _("Sign up"),
    # }
    # context.update(extra_context or {})
    # return render(request, template, context)

    # This one keeps the css but not able to retained user entered data.
    return HttpResponseRedirect(request.META['HTTP_REFERER'])
Ejemplo n.º 10
0
def signup(request, template="accounts/account_signup.html", extra_context=None):
    """
    Signup form. Overriding mezzanine's view function for signup submit
    """
    form = SignupForm(request, request.POST, request.FILES)
    if request.method == "POST" and form.is_valid():
        try:
            new_user = form.save()
        except ValidationError as e:
            if e.message == "Email already in use.":
                messages.error(request, '<p>An account with this email already exists.  Log in '
                                'or click <a href="' + reverse("mezzanine_password_reset") +
                               '" >here</a> to reset password',
                               extra_tags="html")
            else:
                messages.error(request, e.message)
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
        else:
            if not new_user.is_active:
                if settings.ACCOUNTS_APPROVAL_REQUIRED:
                    send_approve_mail(request, new_user)
                    info(request, _("Thanks for signing up! You'll receive "
                                    "an email when your account is activated."))
                else:
                    send_verification_mail(request, new_user, "signup_verify")
                    info(request, _("A verification email has been sent to " + new_user.email +
                                    " with a link that must be clicked prior to your account "
                                    "being activated. If you do not receive this email please "
                                    "check that you entered your address correctly, or your " 
                                    "spam folder as sometimes the email gets flagged as spam. "
                                    "If you entered an incorrect email address, please request "
                                    "an account again."))
                return redirect(next_url(request) or "/")
            else:
                info(request, _("Successfully signed up"))
                auth_login(request, new_user)
                return login_redirect(request)

    # remove the key 'response' from errors as the user would have no idea what it means
    form.errors.pop('response', None)
    messages.error(request, form.errors)

    # TODO: User entered data could be retained only if the following
    # render function would work without messing up the css

    # context = {
    #     "form": form,
    #     "title": _("Sign up"),
    # }
    # context.update(extra_context or {})
    # return render(request, template, context)

    # This one keeps the css but not able to retained user entered data.
    return HttpResponseRedirect(request.META['HTTP_REFERER'])
Ejemplo n.º 11
0
def login(request, template="accounts/account_login.html"):
    """
    Login form.
    """
    form = LoginForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in")}
    return render(request, template, context)
Ejemplo n.º 12
0
def login(request, template="accounts/account_login.html"):
    """
    Login form.
    """
    form = LoginForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Login")}
    return render(request, template, context)
Ejemplo n.º 13
0
def login(request, template="accounts/account_login.html"):
    """
    Login Form
    """
    # Copied from mezzanine/accounts/views so we can override cacheing behavior
    # as it related to the CSRF cookie.
    form = LoginForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Login")}
    return render(request, template, context)
Ejemplo n.º 14
0
def login(request, template="accounts/account_login.html",
          form_class=LoginForm, extra_context=None):
    """
    Login form.
    """
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in"), "next": request.GET.get('next', None)}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
Ejemplo n.º 15
0
def login(request, template="accounts/account_login.html",
          form_class=LoginForm, extra_context=None):
    """
    Login form.
    """
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
Ejemplo n.º 16
0
Archivo: views.py Proyecto: J0WI/fxoss
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = UserRegistrationLeadForm
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        data = form.cleaned_data.copy()

        # ensure user is not a robot
        honeypot = data.pop('superpriority')
        if honeypot:
            raise PermissionDenied

        # save the user
        new_user = form.save()

        # Generate Salesforce Lead
        # Pop non-Salesforce Fields
        for field in ['password1', 'password2']:
            data.pop(field)
        for k, v in SALESFORCE_FIELD_MAPPINGS.items():
            data[v] = data.pop(k)
        data['oid'] = '00DU0000000IrgO'
        # As we're doing the Salesforce POST in the background here,
        # `retURL` is never visited/seen by the user. I believe it
        # is required by Salesforce though, so it should hang around
        # as a placeholder (with a valid URL, just in case).
        data['retURL'] = (request.build_absolute_uri())

        r = requests.post('https://www.salesforce.com/servlet/'
                          'servlet.WebToLead?encoding=UTF-8', data)

        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(request, _("Thanks for signing up! You'll receive "
                                "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(request, _("A verification email has been sent with "
                                "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    return render(request, template, context)
Ejemplo n.º 17
0
def login(request,
          template="base.html",
          form_class=LoginForm,
          extra_context=None):
    """
    Login form.
    """
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        authenticated_user = form.save()
        info(request, _("Successfully logged in"))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in")}
    context.update(extra_context or {})
    return redirect('/', template, context)
Ejemplo n.º 18
0
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    form = ProfileForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            send_verification_mail(request, new_user, "signup_verify")
            info(request, _("A verification email has been sent with "
                            "a link for activating your account."))
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Signup")}
    return render(request, template, context)
Ejemplo n.º 19
0
def signup_verify(request, uidb36=None, token=None):
    """
    View for the link in the verification email sent to a new user
    when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
    is set to ``True``. Activates the user and logs them in,
    redirecting to the URL they tried to access when signing up.
    """
    user = authenticate(uidb36=uidb36, token=token, is_active=False)
    if user is not None:
        user.is_active = True
        user.save()
        auth_login(request, user)
        info(request, _("Successfully signed up"))
        return login_redirect(request)
    else:
        error(request, _("The link you clicked is no longer valid."))
        return redirect("/")
Ejemplo n.º 20
0
def signup_verify(request, uidb36=None, token=None):
    """
    View for the link in the verification email sent to a new user
    when they create an account and ``ACCOUNTS_VERIFICATION_REQUIRED``
    is set to ``True``. Activates the user and logs them in,
    redirecting to the URL they tried to access when signing up.
    """
    user = authenticate(uidb36=uidb36, token=token, is_active=False)
    if user is not None:
        user.is_active = True
        user.save()
        auth_login(request, user)
        info(request, _("Successfully signed up"))
        return login_redirect(request)
    else:
        error(request, _("The link you clicked is no longer valid."))
        return redirect("/")
Ejemplo n.º 21
0
def connect(request):
    error = False
    if request.GET:
        articleAttempt = True
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            user = authenticate(username=username, password=password)
            if user:
                login(request, user)
                return login_redirect(request)
            else:
                obsolete = True
                return render(request, 'login.html', locals())
    else:
        form = LoginForm()
    return render(request, 'login.html', locals())
Ejemplo n.º 22
0
def login(request, template="accounts/account_login.html",
          form_class=LoginForm, extra_context=None):
    """
    Login form - customized from Mezzanine login form so that quota warning message can be
    displayed when the user is logged in.
    """
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        login_msg = "Successfully logged in"
        authenticated_user = form.save()
        add_msg = get_quota_message(authenticated_user)
        if add_msg:
            login_msg += ' - ' + add_msg
        info(request, _(login_msg))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
Ejemplo n.º 23
0
def connect(request):
    error = False
    if request.GET:
        articleAttempt = True
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            user = authenticate(username=username, password=password)
            if user:
                login(request, user)
                return login_redirect(request)
            else:
                obsolete = True
                return render(request, 'login.html', locals())
    else:
        form = LoginForm()
    return render(request, 'login.html', locals())
Ejemplo n.º 24
0
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = get_profile_form()
    form = profile_form(request.POST or None)
    if request.method == "POST" and form.is_valid():
        new_user = form.save()
        if not new_user.is_active:
            send_verification_mail(request, new_user, "signup_verify")
            info(request, _("A verification email has been sent with "
                            "a link for activating your account."))
            return redirect(request.GET.get("next", "/"))
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Signup")}
    return render(request, template, context)
Ejemplo n.º 25
0
def signup(request, template="customers/account_signup.html"):

    stripe_key = settings.STRIPE_PUBLIC_KEY

    subscription_form = SubscriptionForm(request.POST or None)
    customer_form = CustomerForm(request.POST or None)

    if request.method == "POST" and subscription_form.is_valid() and \
        customer_form.is_valid():

        with transaction.commit_on_success():
            save = transaction.savepoint()
            try:
                customer = customer_form.save(commit=False)
                customer.update_card(request.POST['stripeToken'])
                subscription = subscription_form.save(commit=False)
                subscription.customer = customer
                customer.save()
                subscription.save()
                transaction.savepoint_commit(save)

                if not customer.user.is_active:
                    send_verification_mail(request, customer.user, "signup_verify")
                    info(request, _("A verification email has been sent with "
                                    "a link for activating your account."))
                    return redirect(request.GET.get("next", "/"))
                else:
                    info(request, _("Successfully signed up"))
                    auth_login(request, customer.user)
                    return login_redirect(request)

            except Exception as e:
                error(request, e)
                transaction.savepoint_rollback(save)

    context = {
        'customer_form': customer_form,
        'subscription_form': subscription_form,
        'stripe_key': stripe_key,
    }

    return render(request, template, context)
Ejemplo n.º 26
0
def login(request,
          template="accounts/account_login.html",
          form_class=LoginForm,
          extra_context=None):
    """
    Login form - customized from Mezzanine login form so that quota warning message can be
    displayed when the user is logged in.
    """
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        login_msg = "Successfully logged in"
        authenticated_user = form.save()
        add_msg = get_quota_message(authenticated_user)
        if add_msg:
            login_msg += ' - ' + add_msg
        info(request, _(login_msg))
        auth_login(request, authenticated_user)
        return login_redirect(request)
    context = {"form": form, "title": _("Log in")}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
Ejemplo n.º 27
0
def gift_redeem(request, context):
    with transaction.commit_on_success():
        save = transaction.savepoint()
        try:
            code = context["gift_code"]
            gift = GiftSubscription.objects.get(code=code, redeemed=None)
            gift.redeemed = datetime.now()
            gift.save()

            # Create coupon so customer gets free subscription
            coupon = stripe.Coupon.create(percent_off=100, duration="once")["id"]

            customer_form = context["customer_form"]
            customer = customer_form.save(commit=False).customer

            subscription = Subscription(customer=customer, plan=context["plan"])
            subscription.save(coupon=coupon)

            transaction.savepoint_commit(save)

            if not customer.user.is_active:
                send_verification_mail(request, customer.user, "signup_verify")
                info(request, _("A verification email has been sent with " "a link for activating your account."))
                return redirect(request.GET.get("next", "/"))
            else:
                info(request, _("Successfully signed up"))
                auth_login(request, customer.user)
                return login_redirect(request)
            data = {
                "plan": context["plan"],
                "giftee": context["gift_form"].cleaned_data["giftee"],
                "gifter": context["gift_form"].cleaned_data["gifter"],
            }

        except Exception as e:
            transaction.savepoint_rollback(save)
            error(request, e)

    return context
def signup(request, template="accounts/account_signup.html"):
    """
    Signup form.
    """
    profile_form = UserRegistrationLeadForm
    form = profile_form(request.POST or None, request.FILES or None)
    if request.method == "POST" and form.is_valid():
        data = form.cleaned_data.copy()

        # ensure user is not a robot
        honeypot = data.pop('superpriority')
        if honeypot:
            raise PermissionDenied

        # save the user
        new_user = form.save()

        if not new_user.is_active:
            if settings.ACCOUNTS_APPROVAL_REQUIRED:
                send_approve_mail(request, new_user)
                info(
                    request,
                    _("Thanks for signing up! You'll receive "
                      "an email when your account is activated."))
            else:
                send_verification_mail(request, new_user, "signup_verify")
                info(
                    request,
                    _("A verification email has been sent with "
                      "a link for activating your account."))
            return redirect(next_url(request) or "/")
        else:
            info(request, _("Successfully signed up"))
            auth_login(request, new_user)
            return login_redirect(request)
    context = {"form": form, "title": _("Sign up")}
    return render(request, template, context)