We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove passwords from error messages
EvaP sends error messages to the admins when a server error occurs. Post data sent to the page where the error occurred will be included in the message, but passwords must not be included in these messages.
This currently happens e.g. when a user is logging in who has two accounts like described in #791.

Remove passwords from error messages
EvaP sends error messages to the admins when a server error occurs. Post data sent to the page where the error occurred will be included in the message, but passwords must not be included in these messages.
This currently happens e.g. when a user is logging in who has two accounts like described in #791.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `evap/evaluation/views.py`
Content:
```
1 import logging
2 
3 from django.conf import settings
4 from django.contrib import messages
5 from django.contrib.auth import login as auth_login
6 from django.contrib.auth.decorators import login_required
7 from django.core.mail import EmailMessage
8 from django.http import HttpResponse
9 from django.shortcuts import redirect, render
10 from django.utils.translation import ugettext as _
11 from django.core.urlresolvers import resolve, Resolver404
12 from django.views.decorators.http import require_POST
13 
14 from evap.evaluation.forms import NewKeyForm, LoginUsernameForm
15 from evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester
16 
17 logger = logging.getLogger(__name__)
18 
19 
20 def index(request):
21     """Main entry page into EvaP providing all the login options available. The username/password
22        login is thought to be used for internal users, e.g. by connecting to a LDAP directory.
23        The login key mechanism is meant to be used to include external participants, e.g. visiting
24        students or visiting contributors.
25     """
26 
27     # parse the form data into the respective form
28     submit_type = request.POST.get("submit_type", "no_submit")
29     new_key_form = NewKeyForm(request.POST if submit_type == "new_key" else None)
30     login_username_form = LoginUsernameForm(request, request.POST if submit_type == "login_username" else None)
31 
32     # process form data
33     if request.method == 'POST':
34         if new_key_form.is_valid():
35             # user wants a new login key
36             profile = new_key_form.get_user()
37             profile.generate_login_key()
38             profile.save()
39 
40             EmailTemplate.send_login_url_to_user(new_key_form.get_user())
41 
42             messages.success(request, _("We sent you an email with a one-time login URL. Please check your inbox."))
43             return redirect('evaluation:index')
44         elif login_username_form.is_valid():
45             # user would like to login with username and password and passed password test
46             auth_login(request, login_username_form.get_user())
47 
48             # clean up our test cookie
49             if request.session.test_cookie_worked():
50                 request.session.delete_test_cookie()
51 
52     # if not logged in by now, render form
53     if not request.user.is_authenticated():
54         # set test cookie to verify whether they work in the next step
55         request.session.set_test_cookie()
56 
57         template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)
58         return render(request, "index.html", template_data)
59     else:
60         user, __ = UserProfile.objects.get_or_create(username=request.user.username)
61 
62         # check for redirect variable
63         redirect_to = request.GET.get("next", None)
64         if redirect_to is not None:
65             if redirect_to.startswith("/staff/"):
66                 if request.user.is_staff:
67                     return redirect(redirect_to)
68             elif redirect_to.startswith("/grades/"):
69                 if request.user.is_grade_publisher:
70                     return redirect(redirect_to)
71             elif redirect_to.startswith("/contributor/"):
72                 if user.is_contributor:
73                     return redirect(redirect_to)
74             elif redirect_to.startswith("/student/"):
75                 if user.is_participant:
76                     return redirect(redirect_to)
77             else:
78                 try:
79                     resolve(redirect_to)
80                 except Resolver404:
81                     pass
82                 else:
83                     return redirect(redirect_to)
84 
85         # redirect user to appropriate start page
86         if request.user.is_staff:
87             return redirect('staff:index')
88         elif request.user.is_grade_publisher:
89             return redirect('grades:semester_view', Semester.active_semester().id)
90         elif user.is_student:
91             return redirect('student:index')
92         elif user.is_contributor_or_delegate:
93             return redirect('contributor:index')
94         elif user.is_participant:
95             return redirect('student:index')
96         else:
97             return redirect('results:index')
98 
99 
100 def faq(request):
101     return render(request, "faq.html", dict(sections=FaqSection.objects.all()))
102 
103 
104 def legal_notice(request):
105     return render(request, "legal_notice.html", dict())
106 
107 
108 @require_POST
109 @login_required
110 def feedback_send(request):
111     sender_email = request.user.email
112     message = request.POST.get("message")
113     subject = "Feedback from {}".format(sender_email)
114 
115     if message:
116         mail = EmailMessage(
117             subject=subject,
118             body=message,
119             to=[settings.FEEDBACK_EMAIL])
120 
121         try:
122             mail.send()
123             logger.info('Sent feedback email: \n{}\n'.format(mail.message()))
124         except Exception:
125             logger.exception('An exception occurred when sending the following feedback email:\n{}\n'.format(mail.message()))
126 
127     return HttpResponse()
128
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py
--- a/evap/evaluation/views.py
+++ b/evap/evaluation/views.py
@@ -10,6 +10,7 @@
 from django.utils.translation import ugettext as _
 from django.core.urlresolvers import resolve, Resolver404
 from django.views.decorators.http import require_POST
+from django.views.decorators.debug import sensitive_post_parameters
 
 from evap.evaluation.forms import NewKeyForm, LoginUsernameForm
 from evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester
@@ -17,6 +18,7 @@
 logger = logging.getLogger(__name__)
 
 
+@sensitive_post_parameters("password")
 def index(request):
     """Main entry page into EvaP providing all the login options available. The username/password
        login is thought to be used for internal users, e.g. by connecting to a LDAP directory.

{"golden_diff": "diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py\n--- a/evap/evaluation/views.py\n+++ b/evap/evaluation/views.py\n@@ -10,6 +10,7 @@\n from django.utils.translation import ugettext as _\n from django.core.urlresolvers import resolve, Resolver404\n from django.views.decorators.http import require_POST\n+from django.views.decorators.debug import sensitive_post_parameters\n \n from evap.evaluation.forms import NewKeyForm, LoginUsernameForm\n from evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester\n@@ -17,6 +18,7 @@\n logger = logging.getLogger(__name__)\n \n \n+@sensitive_post_parameters(\"password\")\n def index(request):\n     \"\"\"Main entry page into EvaP providing all the login options available. The username/password\n        login is thought to be used for internal users, e.g. by connecting to a LDAP directory.\n", "issue": "Remove passwords from error messages\nEvaP sends error messages to the admins when a server error occurs. Post data sent to the page where the error occurred will be included in the message, but passwords must not be included in these messages.\nThis currently happens e.g. when a user is logging in who has two accounts like described in #791.\n\nRemove passwords from error messages\nEvaP sends error messages to the admins when a server error occurs. Post data sent to the page where the error occurred will be included in the message, but passwords must not be included in these messages.\nThis currently happens e.g. when a user is logging in who has two accounts like described in #791.\n\n", "before_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.contrib.auth import login as auth_login\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.mail import EmailMessage\nfrom django.http import HttpResponse\nfrom django.shortcuts import redirect, render\nfrom django.utils.translation import ugettext as _\nfrom django.core.urlresolvers import resolve, Resolver404\nfrom django.views.decorators.http import require_POST\n\nfrom evap.evaluation.forms import NewKeyForm, LoginUsernameForm\nfrom evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester\n\nlogger = logging.getLogger(__name__)\n\n\ndef index(request):\n    \"\"\"Main entry page into EvaP providing all the login options available. The username/password\n       login is thought to be used for internal users, e.g. by connecting to a LDAP directory.\n       The login key mechanism is meant to be used to include external participants, e.g. visiting\n       students or visiting contributors.\n    \"\"\"\n\n    # parse the form data into the respective form\n    submit_type = request.POST.get(\"submit_type\", \"no_submit\")\n    new_key_form = NewKeyForm(request.POST if submit_type == \"new_key\" else None)\n    login_username_form = LoginUsernameForm(request, request.POST if submit_type == \"login_username\" else None)\n\n    # process form data\n    if request.method == 'POST':\n        if new_key_form.is_valid():\n            # user wants a new login key\n            profile = new_key_form.get_user()\n            profile.generate_login_key()\n            profile.save()\n\n            EmailTemplate.send_login_url_to_user(new_key_form.get_user())\n\n            messages.success(request, _(\"We sent you an email with a one-time login URL. Please check your inbox.\"))\n            return redirect('evaluation:index')\n        elif login_username_form.is_valid():\n            # user would like to login with username and password and passed password test\n            auth_login(request, login_username_form.get_user())\n\n            # clean up our test cookie\n            if request.session.test_cookie_worked():\n                request.session.delete_test_cookie()\n\n    # if not logged in by now, render form\n    if not request.user.is_authenticated():\n        # set test cookie to verify whether they work in the next step\n        request.session.set_test_cookie()\n\n        template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)\n        return render(request, \"index.html\", template_data)\n    else:\n        user, __ = UserProfile.objects.get_or_create(username=request.user.username)\n\n        # check for redirect variable\n        redirect_to = request.GET.get(\"next\", None)\n        if redirect_to is not None:\n            if redirect_to.startswith(\"/staff/\"):\n                if request.user.is_staff:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/grades/\"):\n                if request.user.is_grade_publisher:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/contributor/\"):\n                if user.is_contributor:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/student/\"):\n                if user.is_participant:\n                    return redirect(redirect_to)\n            else:\n                try:\n                    resolve(redirect_to)\n                except Resolver404:\n                    pass\n                else:\n                    return redirect(redirect_to)\n\n        # redirect user to appropriate start page\n        if request.user.is_staff:\n            return redirect('staff:index')\n        elif request.user.is_grade_publisher:\n            return redirect('grades:semester_view', Semester.active_semester().id)\n        elif user.is_student:\n            return redirect('student:index')\n        elif user.is_contributor_or_delegate:\n            return redirect('contributor:index')\n        elif user.is_participant:\n            return redirect('student:index')\n        else:\n            return redirect('results:index')\n\n\ndef faq(request):\n    return render(request, \"faq.html\", dict(sections=FaqSection.objects.all()))\n\n\ndef legal_notice(request):\n    return render(request, \"legal_notice.html\", dict())\n\n\n@require_POST\n@login_required\ndef feedback_send(request):\n    sender_email = request.user.email\n    message = request.POST.get(\"message\")\n    subject = \"Feedback from {}\".format(sender_email)\n\n    if message:\n        mail = EmailMessage(\n            subject=subject,\n            body=message,\n            to=[settings.FEEDBACK_EMAIL])\n\n        try:\n            mail.send()\n            logger.info('Sent feedback email: \\n{}\\n'.format(mail.message()))\n        except Exception:\n            logger.exception('An exception occurred when sending the following feedback email:\\n{}\\n'.format(mail.message()))\n\n    return HttpResponse()\n", "path": "evap/evaluation/views.py"}], "after_files": [{"content": "import logging\n\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.contrib.auth import login as auth_login\nfrom django.contrib.auth.decorators import login_required\nfrom django.core.mail import EmailMessage\nfrom django.http import HttpResponse\nfrom django.shortcuts import redirect, render\nfrom django.utils.translation import ugettext as _\nfrom django.core.urlresolvers import resolve, Resolver404\nfrom django.views.decorators.http import require_POST\nfrom django.views.decorators.debug import sensitive_post_parameters\n\nfrom evap.evaluation.forms import NewKeyForm, LoginUsernameForm\nfrom evap.evaluation.models import UserProfile, FaqSection, EmailTemplate, Semester\n\nlogger = logging.getLogger(__name__)\n\n\n@sensitive_post_parameters(\"password\")\ndef index(request):\n    \"\"\"Main entry page into EvaP providing all the login options available. The username/password\n       login is thought to be used for internal users, e.g. by connecting to a LDAP directory.\n       The login key mechanism is meant to be used to include external participants, e.g. visiting\n       students or visiting contributors.\n    \"\"\"\n\n    # parse the form data into the respective form\n    submit_type = request.POST.get(\"submit_type\", \"no_submit\")\n    new_key_form = NewKeyForm(request.POST if submit_type == \"new_key\" else None)\n    login_username_form = LoginUsernameForm(request, request.POST if submit_type == \"login_username\" else None)\n\n    # process form data\n    if request.method == 'POST':\n        if new_key_form.is_valid():\n            # user wants a new login key\n            profile = new_key_form.get_user()\n            profile.generate_login_key()\n            profile.save()\n\n            EmailTemplate.send_login_url_to_user(new_key_form.get_user())\n\n            messages.success(request, _(\"We sent you an email with a one-time login URL. Please check your inbox.\"))\n            return redirect('evaluation:index')\n        elif login_username_form.is_valid():\n            # user would like to login with username and password and passed password test\n            auth_login(request, login_username_form.get_user())\n\n            # clean up our test cookie\n            if request.session.test_cookie_worked():\n                request.session.delete_test_cookie()\n\n    # if not logged in by now, render form\n    if not request.user.is_authenticated():\n        # set test cookie to verify whether they work in the next step\n        request.session.set_test_cookie()\n\n        template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)\n        return render(request, \"index.html\", template_data)\n    else:\n        user, __ = UserProfile.objects.get_or_create(username=request.user.username)\n\n        # check for redirect variable\n        redirect_to = request.GET.get(\"next\", None)\n        if redirect_to is not None:\n            if redirect_to.startswith(\"/staff/\"):\n                if request.user.is_staff:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/grades/\"):\n                if request.user.is_grade_publisher:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/contributor/\"):\n                if user.is_contributor:\n                    return redirect(redirect_to)\n            elif redirect_to.startswith(\"/student/\"):\n                if user.is_participant:\n                    return redirect(redirect_to)\n            else:\n                try:\n                    resolve(redirect_to)\n                except Resolver404:\n                    pass\n                else:\n                    return redirect(redirect_to)\n\n        # redirect user to appropriate start page\n        if request.user.is_staff:\n            return redirect('staff:index')\n        elif request.user.is_grade_publisher:\n            return redirect('grades:semester_view', Semester.active_semester().id)\n        elif user.is_student:\n            return redirect('student:index')\n        elif user.is_contributor_or_delegate:\n            return redirect('contributor:index')\n        elif user.is_participant:\n            return redirect('student:index')\n        else:\n            return redirect('results:index')\n\n\ndef faq(request):\n    return render(request, \"faq.html\", dict(sections=FaqSection.objects.all()))\n\n\ndef legal_notice(request):\n    return render(request, \"legal_notice.html\", dict())\n\n\n@require_POST\n@login_required\ndef feedback_send(request):\n    sender_email = request.user.email\n    message = request.POST.get(\"message\")\n    subject = \"Feedback from {}\".format(sender_email)\n\n    if message:\n        mail = EmailMessage(\n            subject=subject,\n            body=message,\n            to=[settings.FEEDBACK_EMAIL])\n\n        try:\n            mail.send()\n            logger.info('Sent feedback email: \\n{}\\n'.format(mail.message()))\n        except Exception:\n            logger.exception('An exception occurred when sending the following feedback email:\\n{}\\n'.format(mail.message()))\n\n    return HttpResponse()\n", "path": "evap/evaluation/views.py"}]}