We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Verify email addresses after E-Mail change
When a user changes their email address, it should be verified. allauth provides some views for that which may or may not be useful. Unsure whether email addresses currently are verified at signup, but it would be appropriate for it to use the same mechanism.


--- 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/user/views.py`
Content:
```
1 from allauth.account.models import EmailAddress
2 from allauth.account.views import PasswordChangeView
3 from django.contrib import messages
4 from django.contrib.auth.mixins import LoginRequiredMixin
5 from django.urls import reverse_lazy
6 from django.shortcuts import redirect, render, get_object_or_404
7 from django.urls import reverse
8 from django.views.generic import TemplateView
9 from django.views.generic import UpdateView
10 
11 from nextcloudappstore.core.models import App
12 from nextcloudappstore.user.forms import DeleteAccountForm, AccountForm
13 
14 
15 class TransferAppsView(LoginRequiredMixin, TemplateView):
16     template_name = 'user/transfer-apps.html'
17 
18     def post(self, request, pk):
19         app = get_object_or_404(App, pk=pk, owner=self.request.user)
20         app.ownership_transfer_enabled = not app.ownership_transfer_enabled
21         app.save()
22         return redirect(reverse('user:account-transfer-apps'))
23 
24     def get_context_data(self, **kwargs):
25         context = super().get_context_data(**kwargs)
26         context['apps'] = App.objects.filter(owner=self.request.user)
27         context['acc_page'] = 'account-transfer-apps'
28         return context
29 
30 
31 class ChangeLanguageView(LoginRequiredMixin, TemplateView):
32     template_name = 'user/set-language.html'
33 
34     def get_context_data(self, **kwargs):
35         context = super().get_context_data(**kwargs)
36         context['acc_page'] = 'account-change-language'
37         return context
38 
39 
40 class DeleteAccountView(LoginRequiredMixin, TemplateView):
41     template_name = 'user/delete-account.html'
42 
43     def get_context_data(self, **kwargs):
44         context = super().get_context_data(**kwargs)
45         context['form'] = DeleteAccountForm()
46         context['acc_page'] = 'delete-account'
47         return context
48 
49     def post(self, request, *args, **kwargs):
50         form = DeleteAccountForm(request.POST, user=request.user)
51         if form.is_valid():
52             request.user.delete()
53             return redirect(reverse_lazy('home'))
54         else:
55             return render(request, self.template_name, {'form': form})
56 
57 
58 class AccountView(LoginRequiredMixin, UpdateView):
59     """Display and allow changing of the user's name."""
60 
61     template_name = 'user/account.html'
62     template_name_suffix = ''
63     form_class = AccountForm
64     success_url = reverse_lazy('user:account')
65 
66     def get_context_data(self, **kwargs):
67         context = super().get_context_data(**kwargs)
68         context['acc_page'] = 'account'
69         return context
70 
71     def form_valid(self, form):
72         email = EmailAddress.objects.get_primary(user=self.request.user)
73         email.email = form.cleaned_data['email']
74         email.save()
75         messages.success(self.request, 'Account details saved.')
76         return super().form_valid(form)
77 
78     def get_object(self, queryset=None):
79         return self.request.user
80 
81 
82 class PasswordView(LoginRequiredMixin, PasswordChangeView):
83     """Allow the user to change their password."""
84 
85     template_name = 'user/password.html'
86     success_url = reverse_lazy('user:account-password')
87 
88     def get_context_data(self, **kwargs):
89         context = super().get_context_data(**kwargs)
90         context['acc_page'] = 'password'
91         return context
92 
93 
94 class APITokenView(LoginRequiredMixin, TemplateView):
95     """Display the user's API token, and allow it to be regenerated."""
96 
97     template_name = 'user/api-token.html'
98 
99     def get_context_data(self, **kwargs):
100         context = super().get_context_data(**kwargs)
101         context['acc_page'] = 'api-token'
102         return context
103
```
--- 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/user/views.py b/nextcloudappstore/user/views.py
--- a/nextcloudappstore/user/views.py
+++ b/nextcloudappstore/user/views.py
@@ -70,8 +70,7 @@
 
     def form_valid(self, form):
         email = EmailAddress.objects.get_primary(user=self.request.user)
-        email.email = form.cleaned_data['email']
-        email.save()
+        email.change(None, form.cleaned_data['email'])
         messages.success(self.request, 'Account details saved.')
         return super().form_valid(form)

{"golden_diff": "diff --git a/nextcloudappstore/user/views.py b/nextcloudappstore/user/views.py\n--- a/nextcloudappstore/user/views.py\n+++ b/nextcloudappstore/user/views.py\n@@ -70,8 +70,7 @@\n \n     def form_valid(self, form):\n         email = EmailAddress.objects.get_primary(user=self.request.user)\n-        email.email = form.cleaned_data['email']\n-        email.save()\n+        email.change(None, form.cleaned_data['email'])\n         messages.success(self.request, 'Account details saved.')\n         return super().form_valid(form)\n", "issue": "Verify email addresses after E-Mail change\nWhen a user changes their email address, it should be verified. allauth provides some views for that which may or may not be useful. Unsure whether email addresses currently are verified at signup, but it would be appropriate for it to use the same mechanism.\n\n", "before_files": [{"content": "from allauth.account.models import EmailAddress\nfrom allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.urls import reverse_lazy\nfrom django.shortcuts import redirect, render, get_object_or_404\nfrom django.urls import reverse\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\nfrom nextcloudappstore.core.models import App\nfrom nextcloudappstore.user.forms import DeleteAccountForm, AccountForm\n\n\nclass TransferAppsView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/transfer-apps.html'\n\n    def post(self, request, pk):\n        app = get_object_or_404(App, pk=pk, owner=self.request.user)\n        app.ownership_transfer_enabled = not app.ownership_transfer_enabled\n        app.save()\n        return redirect(reverse('user:account-transfer-apps'))\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['apps'] = App.objects.filter(owner=self.request.user)\n        context['acc_page'] = 'account-transfer-apps'\n        return context\n\n\nclass ChangeLanguageView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/set-language.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account-change-language'\n        return context\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    form_class = AccountForm\n    success_url = reverse_lazy('user: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        email = EmailAddress.objects.get_primary(user=self.request.user)\n        email.email = form.cleaned_data['email']\n        email.save()\n        messages.success(self.request, 'Account details 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('user: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/user/views.py"}], "after_files": [{"content": "from allauth.account.models import EmailAddress\nfrom allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.urls import reverse_lazy\nfrom django.shortcuts import redirect, render, get_object_or_404\nfrom django.urls import reverse\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\nfrom nextcloudappstore.core.models import App\nfrom nextcloudappstore.user.forms import DeleteAccountForm, AccountForm\n\n\nclass TransferAppsView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/transfer-apps.html'\n\n    def post(self, request, pk):\n        app = get_object_or_404(App, pk=pk, owner=self.request.user)\n        app.ownership_transfer_enabled = not app.ownership_transfer_enabled\n        app.save()\n        return redirect(reverse('user:account-transfer-apps'))\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['apps'] = App.objects.filter(owner=self.request.user)\n        context['acc_page'] = 'account-transfer-apps'\n        return context\n\n\nclass ChangeLanguageView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/set-language.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account-change-language'\n        return context\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    form_class = AccountForm\n    success_url = reverse_lazy('user: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        email = EmailAddress.objects.get_primary(user=self.request.user)\n        email.change(None, form.cleaned_data['email'])\n        messages.success(self.request, 'Account details 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('user: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/user/views.py"}]}