prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Identity spoofing via secondary email
  See https://github.com/pennersr/django-allauth/issues/2265
  
  cc: @CarolingerSeilchenspringer @MagdaN @fuzzylogic2000 
  
  </issue>
  <code>
  [start of meinberlin/apps/users/adapters.py]
  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 of meinberlin/apps/users/adapters.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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"}]}