Ejemplo n.º 1
0
def login(request, form_class=LoginForm, template_name="auth/login.html", success_url=None):
    if success_url is None:
        success_url = get_default_redirect(request)
    form = form_class(request.POST or None)
    if form.is_valid():
        return auth_ext_login(request, form.user, success_url,
            remember=form.cleaned_data['remember'])
    return direct_to_template(request, template_name, {'form': form})
Ejemplo n.º 2
0
def signup(request, form_class=SignupForm, template_name="auth/signup.html", success_url=None):
    if success_url is None:
        success_url = get_default_redirect(request)
    form = form_class(request.POST or None)
    if request.method == "POST" and form.is_valid():
        username, password = form.save()
        new_user = get_object_or_404(User, username = username)
        signup_done.send(sender=User, user=new_user)
        if settings.ACCOUNT_EMAIL_VERIFICATION:
            return direct_to_template(request, "account/verification_sent.html", {"email": form.cleaned_data["email"]})
        else:
            user = authenticate(username=username, password=password)
            return auth_ext_login(request, user, success_url)
    return direct_to_template(request, template_name, {"form": form})