prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Identity spoofing via secondary email
  See https://github.com/pennersr/django-allauth/issues/2265
  
  cc: @CarolingerSeilchenspringer @MagdaN @fuzzylogic2000 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `meinberlin/apps/users/adapters.py`
  Content:
  ```
  1 import re
  2 from urllib.parse import quote
  3 
  4 from allauth.account.adapter import DefaultAccountAdapter
  5 from django.conf import settings
  6 from django.utils.http import is_safe_url
  7 
  8 from adhocracy4.emails.mixins import SyncEmailMixin
  9 from meinberlin.apps.contrib.emails import Email
  10 from meinberlin.apps.users import USERNAME_INVALID_MESSAGE
  11 from meinberlin.apps.users import USERNAME_REGEX
  12 
  13 
  14 class UserAccountEmail(SyncEmailMixin, Email):
  15     def get_receivers(self):
  16         return [self.object]
  17 
  18     @property
  19     def template_name(self):
  20         return self.kwargs['template_name']
  21 
  22     def get_context(self):
  23         context = super().get_context()
  24         context['contact_email'] = settings.CONTACT_EMAIL
  25         return context
  26 
  27 
  28 class AccountAdapter(DefaultAccountAdapter):
  29     username_regex = re.compile(USERNAME_REGEX)
  30     error_messages = dict(
  31         DefaultAccountAdapter.error_messages,
  32         invalid_username=USERNAME_INVALID_MESSAGE
  33     )
  34 
  35     def get_email_confirmation_url(self, request, emailconfirmation):
  36         url = super().get_email_confirmation_url(request, emailconfirmation)
  37         if 'next' in request.POST and is_safe_url(request.POST['next']):
  38             return '{}?next={}'.format(url, quote(request.POST['next']))
  39         else:
  40             return url
  41 
  42     def send_mail(self, template_prefix, email, context):
  43         user = context['user']
  44         return UserAccountEmail.send(
  45             user,
  46             template_name=template_prefix,
  47             **context
  48         )
  49 
  50     def get_email_confirmation_redirect_url(self, request):
  51         if 'next' in request.GET and is_safe_url(request.GET['next']):
  52             return request.GET['next']
  53         else:
  54             return super().get_email_confirmation_redirect_url(request)
  55
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/meinberlin/apps/users/adapters.py b/meinberlin/apps/users/adapters.py
  --- a/meinberlin/apps/users/adapters.py
  +++ b/meinberlin/apps/users/adapters.py
  @@ -40,9 +40,8 @@
               return url
   
       def send_mail(self, template_prefix, email, context):
  -        user = context['user']
           return UserAccountEmail.send(
  -            user,
  +            email,
               template_name=template_prefix,
               **context
           )
  
verification_info: {"golden_diff": "diff --git a/meinberlin/apps/users/adapters.py b/meinberlin/apps/users/adapters.py\n--- a/meinberlin/apps/users/adapters.py\n+++ b/meinberlin/apps/users/adapters.py\n@@ -40,9 +40,8 @@\n             return url\n \n     def send_mail(self, template_prefix, email, context):\n-        user = context['user']\n         return UserAccountEmail.send(\n-            user,\n+            email,\n             template_name=template_prefix,\n             **context\n         )\n", "issue": "Identity spoofing via secondary email\nSee https://github.com/pennersr/django-allauth/issues/2265\r\n\r\ncc: @CarolingerSeilchenspringer @MagdaN @fuzzylogic2000 \n", "before_files": [{"content": "import re\nfrom urllib.parse import quote\n\nfrom allauth.account.adapter import DefaultAccountAdapter\nfrom django.conf import settings\nfrom django.utils.http import is_safe_url\n\nfrom adhocracy4.emails.mixins import SyncEmailMixin\nfrom meinberlin.apps.contrib.emails import Email\nfrom meinberlin.apps.users import USERNAME_INVALID_MESSAGE\nfrom meinberlin.apps.users import USERNAME_REGEX\n\n\nclass UserAccountEmail(SyncEmailMixin, Email):\n    def get_receivers(self):\n        return [self.object]\n\n    @property\n    def template_name(self):\n        return self.kwargs['template_name']\n\n    def get_context(self):\n        context = super().get_context()\n        context['contact_email'] = settings.CONTACT_EMAIL\n        return context\n\n\nclass AccountAdapter(DefaultAccountAdapter):\n    username_regex = re.compile(USERNAME_REGEX)\n    error_messages = dict(\n        DefaultAccountAdapter.error_messages,\n        invalid_username=USERNAME_INVALID_MESSAGE\n    )\n\n    def get_email_confirmation_url(self, request, emailconfirmation):\n        url = super().get_email_confirmation_url(request, emailconfirmation)\n        if 'next' in request.POST and is_safe_url(request.POST['next']):\n            return '{}?next={}'.format(url, quote(request.POST['next']))\n        else:\n            return url\n\n    def send_mail(self, template_prefix, email, context):\n        user = context['user']\n        return UserAccountEmail.send(\n            user,\n            template_name=template_prefix,\n            **context\n        )\n\n    def get_email_confirmation_redirect_url(self, request):\n        if 'next' in request.GET and is_safe_url(request.GET['next']):\n            return request.GET['next']\n        else:\n            return super().get_email_confirmation_redirect_url(request)\n", "path": "meinberlin/apps/users/adapters.py"}], "after_files": [{"content": "import re\nfrom urllib.parse import quote\n\nfrom allauth.account.adapter import DefaultAccountAdapter\nfrom django.conf import settings\nfrom django.utils.http import is_safe_url\n\nfrom adhocracy4.emails.mixins import SyncEmailMixin\nfrom meinberlin.apps.contrib.emails import Email\nfrom meinberlin.apps.users import USERNAME_INVALID_MESSAGE\nfrom meinberlin.apps.users import USERNAME_REGEX\n\n\nclass UserAccountEmail(SyncEmailMixin, Email):\n    def get_receivers(self):\n        return [self.object]\n\n    @property\n    def template_name(self):\n        return self.kwargs['template_name']\n\n    def get_context(self):\n        context = super().get_context()\n        context['contact_email'] = settings.CONTACT_EMAIL\n        return context\n\n\nclass AccountAdapter(DefaultAccountAdapter):\n    username_regex = re.compile(USERNAME_REGEX)\n    error_messages = dict(\n        DefaultAccountAdapter.error_messages,\n        invalid_username=USERNAME_INVALID_MESSAGE\n    )\n\n    def get_email_confirmation_url(self, request, emailconfirmation):\n        url = super().get_email_confirmation_url(request, emailconfirmation)\n        if 'next' in request.POST and is_safe_url(request.POST['next']):\n            return '{}?next={}'.format(url, quote(request.POST['next']))\n        else:\n            return url\n\n    def send_mail(self, template_prefix, email, context):\n        return UserAccountEmail.send(\n            email,\n            template_name=template_prefix,\n            **context\n        )\n\n    def get_email_confirmation_redirect_url(self, request):\n        if 'next' in request.GET and is_safe_url(request.GET['next']):\n            return request.GET['next']\n        else:\n            return super().get_email_confirmation_redirect_url(request)\n", "path": "meinberlin/apps/users/adapters.py"}]}