We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Delete user account
A user should be able to delete his account by hitting and confirming it on the download page. The confirmation should not be able to trigger by accident, Github's delete repo ui is a good example.

Before deleting his account, a user will be warned that all his comments and apps will be deleted.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nextcloudappstore/urls.py`
Content:
```
1 from allauth.account.views import signup
2 from allauth.socialaccount.views import signup as social_signup
3 from csp.decorators import csp_exempt
4 from django.conf.urls import url, include
5 from django.contrib import admin
6 from nextcloudappstore.core.user.views import PasswordView, AccountView, \
7     APITokenView
8 from nextcloudappstore.core.views import CategoryAppListView, AppDetailView, \
9     app_description, AppReleasesView, AppUploadView, LegalNoticeView
10 
11 urlpatterns = [
12     url(r'^$', CategoryAppListView.as_view(), {'id': None}, name='home'),
13     url(r"^signup/$", csp_exempt(signup), name="account_signup"),
14     url(r"^social/signup/$", csp_exempt(social_signup),
15         name="socialaccount_signup"),
16     url(r'^', include('allauth.urls')),
17     url(r'^account/?$', AccountView.as_view(), name='account'),
18     url(r'^account/password/?$', PasswordView.as_view(),
19         name='account-password'),
20     url(r'^account/token/?$', APITokenView.as_view(),
21         name='account-api-token'),
22     url(r'^legal/?$', LegalNoticeView.as_view(), name='legal-notice'),
23     url(r'^categories/(?P<id>[\w]*)/?$', CategoryAppListView.as_view(),
24         name='category-app-list'),
25     url(r'^app/upload/?$', AppUploadView.as_view(), name='app-upload'),
26     url(r'^app/(?P<id>[\w_]+)/?$', AppDetailView.as_view(), name='app-detail'),
27     url(r'^app/(?P<id>[\w_]+)/releases/?$', AppReleasesView.as_view(),
28         name='app-releases'),
29     url(r'^app/(?P<id>[\w_]+)/description/?$', app_description,
30         name='app-description'),
31     url(r'^api/', include('nextcloudappstore.core.api.urls',
32                           namespace='api')),
33     url(r'^admin/', admin.site.urls),
34 ]
35
```

Path: `nextcloudappstore/core/user/views.py`
Content:
```
1 from allauth.account.views import PasswordChangeView
2 from django.contrib import messages
3 from django.contrib.auth.mixins import LoginRequiredMixin
4 from django.contrib.auth.models import User
5 from django.core.urlresolvers import reverse_lazy
6 from django.views.generic import TemplateView
7 from django.views.generic import UpdateView
8 
9 
10 class AccountView(LoginRequiredMixin, UpdateView):
11     """Display and allow changing of the user's name."""
12 
13     template_name = 'user/account.html'
14     template_name_suffix = ''
15     model = User
16     fields = ['first_name', 'last_name']
17     success_url = reverse_lazy('account')
18 
19     def get_context_data(self, **kwargs):
20         context = super().get_context_data(**kwargs)
21         context['acc_page'] = 'account'
22         return context
23 
24     def form_valid(self, form):
25         messages.success(self.request, 'Name saved.')
26         return super().form_valid(form)
27 
28     def get_object(self, queryset=None):
29         return self.request.user
30 
31 
32 class PasswordView(LoginRequiredMixin, PasswordChangeView):
33     """Allow the user to change their password."""
34 
35     template_name = 'user/password.html'
36     success_url = reverse_lazy('account-password')
37 
38     def get_context_data(self, **kwargs):
39         context = super().get_context_data(**kwargs)
40         context['acc_page'] = 'password'
41         return context
42 
43 
44 class APITokenView(LoginRequiredMixin, TemplateView):
45     """Display the user's API token, and allow it to be regenerated."""
46 
47     template_name = 'user/api-token.html'
48 
49     def get_context_data(self, **kwargs):
50         context = super().get_context_data(**kwargs)
51         context['acc_page'] = 'api-token'
52         return context
53
```

Path: `nextcloudappstore/core/user/forms.py`
Content:
```
1 from django import forms
2 from captcha.fields import ReCaptchaField
3 
4 
5 class SignupFormRecaptcha(forms.Form):
6     """integrate a recaptcha field."""
7     recaptcha = ReCaptchaField()
8 
9     def signup(self, request, user):
10         pass
11
```
--- 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/nextcloudappstore/core/user/forms.py b/nextcloudappstore/core/user/forms.py
--- a/nextcloudappstore/core/user/forms.py
+++ b/nextcloudappstore/core/user/forms.py
@@ -1,5 +1,7 @@
 from django import forms
 from captcha.fields import ReCaptchaField
+from django.forms import EmailField
+from django.utils.translation import ugettext_lazy as _
 
 
 class SignupFormRecaptcha(forms.Form):
@@ -8,3 +10,19 @@
 
     def signup(self, request, user):
         pass
+
+
+class DeleteAccountForm(forms.Form):
+    email = EmailField(required=True, label=_('Your e-mail address'))
+
+    def __init__(self, *args, **kwargs):
+        self.user = kwargs.pop('user', None)
+        super().__init__(*args, **kwargs)
+
+    def clean_email(self):
+        email = self.cleaned_data.get('email')
+        if self.user and self.user.email == email:
+            return email
+        else:
+            raise forms.ValidationError(_(
+                'The given e-mail address does not match your e-mail address'))
diff --git a/nextcloudappstore/core/user/views.py b/nextcloudappstore/core/user/views.py
--- a/nextcloudappstore/core/user/views.py
+++ b/nextcloudappstore/core/user/views.py
@@ -3,9 +3,30 @@
 from django.contrib.auth.mixins import LoginRequiredMixin
 from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse_lazy
+from django.shortcuts import redirect, render
 from django.views.generic import TemplateView
 from django.views.generic import UpdateView
 
+from nextcloudappstore.core.user.forms import DeleteAccountForm
+
+
+class DeleteAccountView(LoginRequiredMixin, TemplateView):
+    template_name = 'user/delete-account.html'
+
+    def get_context_data(self, **kwargs):
+        context = super().get_context_data(**kwargs)
+        context['form'] = DeleteAccountForm()
+        context['acc_page'] = 'delete-account'
+        return context
+
+    def post(self, request, *args, **kwargs):
+        form = DeleteAccountForm(request.POST, user=request.user)
+        if form.is_valid():
+            request.user.delete()
+            return redirect(reverse_lazy('home'))
+        else:
+            return render(request, self.template_name, {'form': form})
+
 
 class AccountView(LoginRequiredMixin, UpdateView):
     """Display and allow changing of the user's name."""
diff --git a/nextcloudappstore/urls.py b/nextcloudappstore/urls.py
--- a/nextcloudappstore/urls.py
+++ b/nextcloudappstore/urls.py
@@ -4,7 +4,7 @@
 from django.conf.urls import url, include
 from django.contrib import admin
 from nextcloudappstore.core.user.views import PasswordView, AccountView, \
-    APITokenView
+    APITokenView, DeleteAccountView
 from nextcloudappstore.core.views import CategoryAppListView, AppDetailView, \
     app_description, AppReleasesView, AppUploadView, LegalNoticeView
 
@@ -19,6 +19,8 @@
         name='account-password'),
     url(r'^account/token/?$', APITokenView.as_view(),
         name='account-api-token'),
+    url(r'^account/delete/?$', DeleteAccountView.as_view(),
+        name='account-deletion'),
     url(r'^legal/?$', LegalNoticeView.as_view(), name='legal-notice'),
     url(r'^categories/(?P<id>[\w]*)/?$', CategoryAppListView.as_view(),
         name='category-app-list'),

{"golden_diff": "diff --git a/nextcloudappstore/core/user/forms.py b/nextcloudappstore/core/user/forms.py\n--- a/nextcloudappstore/core/user/forms.py\n+++ b/nextcloudappstore/core/user/forms.py\n@@ -1,5 +1,7 @@\n from django import forms\n from captcha.fields import ReCaptchaField\n+from django.forms import EmailField\n+from django.utils.translation import ugettext_lazy as _\n \n \n class SignupFormRecaptcha(forms.Form):\n@@ -8,3 +10,19 @@\n \n     def signup(self, request, user):\n         pass\n+\n+\n+class DeleteAccountForm(forms.Form):\n+    email = EmailField(required=True, label=_('Your e-mail address'))\n+\n+    def __init__(self, *args, **kwargs):\n+        self.user = kwargs.pop('user', None)\n+        super().__init__(*args, **kwargs)\n+\n+    def clean_email(self):\n+        email = self.cleaned_data.get('email')\n+        if self.user and self.user.email == email:\n+            return email\n+        else:\n+            raise forms.ValidationError(_(\n+                'The given e-mail address does not match your e-mail address'))\ndiff --git a/nextcloudappstore/core/user/views.py b/nextcloudappstore/core/user/views.py\n--- a/nextcloudappstore/core/user/views.py\n+++ b/nextcloudappstore/core/user/views.py\n@@ -3,9 +3,30 @@\n from django.contrib.auth.mixins import LoginRequiredMixin\n from django.contrib.auth.models import User\n from django.core.urlresolvers import reverse_lazy\n+from django.shortcuts import redirect, render\n from django.views.generic import TemplateView\n from django.views.generic import UpdateView\n \n+from nextcloudappstore.core.user.forms import DeleteAccountForm\n+\n+\n+class DeleteAccountView(LoginRequiredMixin, TemplateView):\n+    template_name = 'user/delete-account.html'\n+\n+    def get_context_data(self, **kwargs):\n+        context = super().get_context_data(**kwargs)\n+        context['form'] = DeleteAccountForm()\n+        context['acc_page'] = 'delete-account'\n+        return context\n+\n+    def post(self, request, *args, **kwargs):\n+        form = DeleteAccountForm(request.POST, user=request.user)\n+        if form.is_valid():\n+            request.user.delete()\n+            return redirect(reverse_lazy('home'))\n+        else:\n+            return render(request, self.template_name, {'form': form})\n+\n \n class AccountView(LoginRequiredMixin, UpdateView):\n     \"\"\"Display and allow changing of the user's name.\"\"\"\ndiff --git a/nextcloudappstore/urls.py b/nextcloudappstore/urls.py\n--- a/nextcloudappstore/urls.py\n+++ b/nextcloudappstore/urls.py\n@@ -4,7 +4,7 @@\n from django.conf.urls import url, include\n from django.contrib import admin\n from nextcloudappstore.core.user.views import PasswordView, AccountView, \\\n-    APITokenView\n+    APITokenView, DeleteAccountView\n from nextcloudappstore.core.views import CategoryAppListView, AppDetailView, \\\n     app_description, AppReleasesView, AppUploadView, LegalNoticeView\n \n@@ -19,6 +19,8 @@\n         name='account-password'),\n     url(r'^account/token/?$', APITokenView.as_view(),\n         name='account-api-token'),\n+    url(r'^account/delete/?$', DeleteAccountView.as_view(),\n+        name='account-deletion'),\n     url(r'^legal/?$', LegalNoticeView.as_view(), name='legal-notice'),\n     url(r'^categories/(?P<id>[\\w]*)/?$', CategoryAppListView.as_view(),\n         name='category-app-list'),\n", "issue": "Delete user account\nA user should be able to delete his account by hitting and confirming it on the download page. The confirmation should not be able to trigger by accident, Github's delete repo ui is a good example.\n\nBefore deleting his account, a user will be warned that all his comments and apps will be deleted.\n\n", "before_files": [{"content": "from allauth.account.views import signup\nfrom allauth.socialaccount.views import signup as social_signup\nfrom csp.decorators import csp_exempt\nfrom django.conf.urls import url, include\nfrom django.contrib import admin\nfrom nextcloudappstore.core.user.views import PasswordView, AccountView, \\\n    APITokenView\nfrom nextcloudappstore.core.views import CategoryAppListView, AppDetailView, \\\n    app_description, AppReleasesView, AppUploadView, LegalNoticeView\n\nurlpatterns = [\n    url(r'^$', CategoryAppListView.as_view(), {'id': None}, name='home'),\n    url(r\"^signup/$\", csp_exempt(signup), name=\"account_signup\"),\n    url(r\"^social/signup/$\", csp_exempt(social_signup),\n        name=\"socialaccount_signup\"),\n    url(r'^', include('allauth.urls')),\n    url(r'^account/?$', AccountView.as_view(), name='account'),\n    url(r'^account/password/?$', PasswordView.as_view(),\n        name='account-password'),\n    url(r'^account/token/?$', APITokenView.as_view(),\n        name='account-api-token'),\n    url(r'^legal/?$', LegalNoticeView.as_view(), name='legal-notice'),\n    url(r'^categories/(?P<id>[\\w]*)/?$', CategoryAppListView.as_view(),\n        name='category-app-list'),\n    url(r'^app/upload/?$', AppUploadView.as_view(), name='app-upload'),\n    url(r'^app/(?P<id>[\\w_]+)/?$', AppDetailView.as_view(), name='app-detail'),\n    url(r'^app/(?P<id>[\\w_]+)/releases/?$', AppReleasesView.as_view(),\n        name='app-releases'),\n    url(r'^app/(?P<id>[\\w_]+)/description/?$', app_description,\n        name='app-description'),\n    url(r'^api/', include('nextcloudappstore.core.api.urls',\n                          namespace='api')),\n    url(r'^admin/', admin.site.urls),\n]\n", "path": "nextcloudappstore/urls.py"}, {"content": "from allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.contrib.auth.models import User\nfrom django.core.urlresolvers import reverse_lazy\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\n\nclass AccountView(LoginRequiredMixin, UpdateView):\n    \"\"\"Display and allow changing of the user's name.\"\"\"\n\n    template_name = 'user/account.html'\n    template_name_suffix = ''\n    model = User\n    fields = ['first_name', 'last_name']\n    success_url = reverse_lazy('account')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account'\n        return context\n\n    def form_valid(self, form):\n        messages.success(self.request, 'Name saved.')\n        return super().form_valid(form)\n\n    def get_object(self, queryset=None):\n        return self.request.user\n\n\nclass PasswordView(LoginRequiredMixin, PasswordChangeView):\n    \"\"\"Allow the user to change their password.\"\"\"\n\n    template_name = 'user/password.html'\n    success_url = reverse_lazy('account-password')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'password'\n        return context\n\n\nclass APITokenView(LoginRequiredMixin, TemplateView):\n    \"\"\"Display the user's API token, and allow it to be regenerated.\"\"\"\n\n    template_name = 'user/api-token.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'api-token'\n        return context\n", "path": "nextcloudappstore/core/user/views.py"}, {"content": "from django import forms\nfrom captcha.fields import ReCaptchaField\n\n\nclass SignupFormRecaptcha(forms.Form):\n    \"\"\"integrate a recaptcha field.\"\"\"\n    recaptcha = ReCaptchaField()\n\n    def signup(self, request, user):\n        pass\n", "path": "nextcloudappstore/core/user/forms.py"}], "after_files": [{"content": "from allauth.account.views import signup\nfrom allauth.socialaccount.views import signup as social_signup\nfrom csp.decorators import csp_exempt\nfrom django.conf.urls import url, include\nfrom django.contrib import admin\nfrom nextcloudappstore.core.user.views import PasswordView, AccountView, \\\n    APITokenView, DeleteAccountView\nfrom nextcloudappstore.core.views import CategoryAppListView, AppDetailView, \\\n    app_description, AppReleasesView, AppUploadView, LegalNoticeView\n\nurlpatterns = [\n    url(r'^$', CategoryAppListView.as_view(), {'id': None}, name='home'),\n    url(r\"^signup/$\", csp_exempt(signup), name=\"account_signup\"),\n    url(r\"^social/signup/$\", csp_exempt(social_signup),\n        name=\"socialaccount_signup\"),\n    url(r'^', include('allauth.urls')),\n    url(r'^account/?$', AccountView.as_view(), name='account'),\n    url(r'^account/password/?$', PasswordView.as_view(),\n        name='account-password'),\n    url(r'^account/token/?$', APITokenView.as_view(),\n        name='account-api-token'),\n    url(r'^account/delete/?$', DeleteAccountView.as_view(),\n        name='account-deletion'),\n    url(r'^legal/?$', LegalNoticeView.as_view(), name='legal-notice'),\n    url(r'^categories/(?P<id>[\\w]*)/?$', CategoryAppListView.as_view(),\n        name='category-app-list'),\n    url(r'^app/upload/?$', AppUploadView.as_view(), name='app-upload'),\n    url(r'^app/(?P<id>[\\w_]+)/?$', AppDetailView.as_view(), name='app-detail'),\n    url(r'^app/(?P<id>[\\w_]+)/releases/?$', AppReleasesView.as_view(),\n        name='app-releases'),\n    url(r'^app/(?P<id>[\\w_]+)/description/?$', app_description,\n        name='app-description'),\n    url(r'^api/', include('nextcloudappstore.core.api.urls',\n                          namespace='api')),\n    url(r'^admin/', admin.site.urls),\n]\n", "path": "nextcloudappstore/urls.py"}, {"content": "from allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.contrib.auth.models import User\nfrom django.core.urlresolvers import reverse_lazy\nfrom django.shortcuts import redirect, render\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\nfrom nextcloudappstore.core.user.forms import DeleteAccountForm\n\n\nclass DeleteAccountView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/delete-account.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['form'] = DeleteAccountForm()\n        context['acc_page'] = 'delete-account'\n        return context\n\n    def post(self, request, *args, **kwargs):\n        form = DeleteAccountForm(request.POST, user=request.user)\n        if form.is_valid():\n            request.user.delete()\n            return redirect(reverse_lazy('home'))\n        else:\n            return render(request, self.template_name, {'form': form})\n\n\nclass AccountView(LoginRequiredMixin, UpdateView):\n    \"\"\"Display and allow changing of the user's name.\"\"\"\n\n    template_name = 'user/account.html'\n    template_name_suffix = ''\n    model = User\n    fields = ['first_name', 'last_name']\n    success_url = reverse_lazy('account')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account'\n        return context\n\n    def form_valid(self, form):\n        messages.success(self.request, 'Name saved.')\n        return super().form_valid(form)\n\n    def get_object(self, queryset=None):\n        return self.request.user\n\n\nclass PasswordView(LoginRequiredMixin, PasswordChangeView):\n    \"\"\"Allow the user to change their password.\"\"\"\n\n    template_name = 'user/password.html'\n    success_url = reverse_lazy('account-password')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'password'\n        return context\n\n\nclass APITokenView(LoginRequiredMixin, TemplateView):\n    \"\"\"Display the user's API token, and allow it to be regenerated.\"\"\"\n\n    template_name = 'user/api-token.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'api-token'\n        return context\n", "path": "nextcloudappstore/core/user/views.py"}, {"content": "from django import forms\nfrom captcha.fields import ReCaptchaField\nfrom django.forms import EmailField\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass SignupFormRecaptcha(forms.Form):\n    \"\"\"integrate a recaptcha field.\"\"\"\n    recaptcha = ReCaptchaField()\n\n    def signup(self, request, user):\n        pass\n\n\nclass DeleteAccountForm(forms.Form):\n    email = EmailField(required=True, label=_('Your e-mail address'))\n\n    def __init__(self, *args, **kwargs):\n        self.user = kwargs.pop('user', None)\n        super().__init__(*args, **kwargs)\n\n    def clean_email(self):\n        email = self.cleaned_data.get('email')\n        if self.user and self.user.email == email:\n            return email\n        else:\n            raise forms.ValidationError(_(\n                'The given e-mail address does not match your e-mail address'))\n", "path": "nextcloudappstore/core/user/forms.py"}]}