<commit_before>from django.contrib.auth.views import login as base_login
from django.contrib.auth import logout as auth_logout
from django.shortcuts import render
from django.http import HttpResponseRedirect

from .forms import ForgottenPasswordForm


def login(request):
    return base_login(request, template_name="registration/login.haml")


def logout(request):
    auth_logout(request)
    return HttpResponseRedirect("/")


def forgotten_password(request):
    if request.method == 'GET':
        return render(request, 'registration/forgotten_password.haml', {"form": ForgottenPasswordForm()})<commit_msg>[enh] handle bad form data<commit_after>from django.contrib.auth.views import login as base_login
from django.contrib.auth import logout as auth_logout
from django.shortcuts import render
from django.http import HttpResponseRedirect

from .forms import ForgottenPasswordForm


def login(request):
    return base_login(request, template_name="registration/login.haml")


def logout(request):
    auth_logout(request)
    return HttpResponseRedirect("/")


def forgotten_password(request):
    if request.method == 'GET':
        return render(request, 'registration/forgotten_password.haml', {"form": ForgottenPasswordForm()})

    form = ForgottenPasswordForm(request.POST)

    if not form.is_valid():
        return render(request, 'registration/forgotten_password.haml', {"form": form})
{'fraction_non_alphanumeric': 0.0962223806129722, 'fraction_numerical': 0.0, 'mean_word_length': 5.5, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5076997', 'n_tokens_mistral': 400, 'n_tokens_neox': 383, 'n_words': 101}