prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  (User creation) Some fields are required that should not be
  Address, zip and phone should not be required. People will complain.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/authentication/forms.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 import datetime
  4 import re
  5 
  6 from django import forms
  7 from django.contrib import auth
  8 from django.utils.translation import ugettext as _
  9 
  10 from apps.authentication.models import OnlineUser as User, Email
  11 
  12 class LoginForm(forms.Form):
  13     username = forms.CharField(widget=forms.TextInput(), label=_("Brukernavn"), max_length=50)
  14     password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u"Passord"))
  15     user = None
  16 
  17     def clean(self):
  18         if self._errors:
  19             return
  20     
  21         user = auth.authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])
  22 
  23         if user:
  24             if user.is_active:
  25                 self.user = user
  26             else:
  27                 self._errors['username'] = self.error_class([_(u"Din konto er ikke aktiv. Forsøk gjenoppretning av passord.")])
  28         else:
  29             self._errors['username'] = self.error_class([_(u"Kontoen eksisterer ikke, eller kombinasjonen av brukernavn og passord er feil.")])
  30         return self.cleaned_data
  31 
  32     def login(self, request):
  33         try:
  34             User.objects.get(username=request.POST['username'])
  35         except:
  36             return False
  37         if self.is_valid():
  38             auth.login(request, self.user)
  39             request.session.set_expiry(0)
  40             return True
  41         return False
  42 
  43 class RegisterForm(forms.Form):
  44     username = forms.CharField(label=_("Brukernavn"), max_length=20)
  45     first_name = forms.CharField(label=_("Fornavn"), max_length=50)
  46     last_name = forms.CharField(label=_("Etternavn"), max_length=50)
  47     email = forms.EmailField(label=_("Epost"), max_length=50)
  48     password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_("Passord"))
  49     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_("Gjenta passord"))
  50     address = forms.CharField(label=_("Adresse"), max_length=50)
  51     zip_code = forms.CharField(label=_("Postnummer"), max_length=4)
  52     phone = forms.CharField(label=_("Telefon"), max_length=20)
  53     
  54     def clean(self):
  55         super(RegisterForm, self).clean()
  56         if self.is_valid():
  57             cleaned_data = self.cleaned_data
  58 
  59             # Check passwords
  60             if cleaned_data['password'] != cleaned_data['repeat_password']:
  61                 self._errors['repeat_password'] = self.error_class([_(u"Passordene er ikke like.")])
  62 
  63             # Check username
  64             username = cleaned_data['username']
  65             if User.objects.filter(username=username).count() > 0:
  66                 self._errors['username'] = self.error_class([_(u"Brukernavnet er allerede registrert.")])
  67             if not re.match("^[a-zA-Z0-9_-]+$", username):
  68                 self._errors['username'] = self.error_class([_(u"Ditt brukernavn inneholdt ulovlige tegn. Lovlige tegn: a-Z 0-9 - _")])
  69 
  70             # Check email
  71             email = cleaned_data['email']
  72             if Email.objects.filter(email=email).count() > 0:
  73                 self._errors['email'] = self.error_class([_(u"Det fins allerede en bruker med denne epostadressen.")])
  74 
  75             # ZIP code digits only
  76             zip_code = cleaned_data['zip_code']
  77             if len(zip_code) != 4 or not zip_code.isdigit():
  78                 self._errors['zip_code'] = self.error_class([_(u"Postnummer må bestå av fire siffer.")])
  79 
  80             return cleaned_data 
  81 
  82 class RecoveryForm(forms.Form):
  83     email = forms.EmailField(label="Email", max_length=50)
  84 
  85 class ChangePasswordForm(forms.Form):
  86     new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u"Nytt passord"))
  87     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u"Gjenta passord"))
  88 
  89     def clean(self):
  90         super(ChangePasswordForm, self).clean()
  91         if self.is_valid():
  92             cleaned_data = self.cleaned_data
  93 
  94             # Check passwords
  95             if cleaned_data['new_password'] != cleaned_data['repeat_password']:
  96                 self._errors['repeat_password'] = self.error_class([_(u"Passordene er ikke like.")])
  97 
  98             return cleaned_data
  99 
  100 
  101 class NewEmailForm(forms.Form):
  102     new_email = forms.EmailField(_(u"ny epostadresse"))
  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()
  
  ```
  
golden_diff: diff --git a/apps/authentication/forms.py b/apps/authentication/forms.py
  --- a/apps/authentication/forms.py
  +++ b/apps/authentication/forms.py
  @@ -47,9 +47,9 @@
       email = forms.EmailField(label=_("Epost"), max_length=50)
       password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_("Passord"))
       repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_("Gjenta passord"))
  -    address = forms.CharField(label=_("Adresse"), max_length=50)
  -    zip_code = forms.CharField(label=_("Postnummer"), max_length=4)
  -    phone = forms.CharField(label=_("Telefon"), max_length=20)
  +    address = forms.CharField(label=_("Adresse"), max_length=50, required=False)
  +    zip_code = forms.CharField(label=_("Postnummer"), max_length=4, required=False)
  +    phone = forms.CharField(label=_("Telefon"), max_length=20, required=False)
       
       def clean(self):
           super(RegisterForm, self).clean()
  @@ -74,8 +74,9 @@
   
               # ZIP code digits only
               zip_code = cleaned_data['zip_code']
  -            if len(zip_code) != 4 or not zip_code.isdigit():
  -                self._errors['zip_code'] = self.error_class([_(u"Postnummer må bestå av fire siffer.")])
  +            if len(zip_code) != 0:
  +                if len(zip_code) != 4 or len(zip_code) != 0 or not zip_code.isdigit():
  +                    self._errors['zip_code'] = self.error_class([_(u"Postnummer må bestå av fire siffer.")])
   
               return cleaned_data
  
verification_info: {"golden_diff": "diff --git a/apps/authentication/forms.py b/apps/authentication/forms.py\n--- a/apps/authentication/forms.py\n+++ b/apps/authentication/forms.py\n@@ -47,9 +47,9 @@\n     email = forms.EmailField(label=_(\"Epost\"), max_length=50)\n     password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Passord\"))\n     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Gjenta passord\"))\n-    address = forms.CharField(label=_(\"Adresse\"), max_length=50)\n-    zip_code = forms.CharField(label=_(\"Postnummer\"), max_length=4)\n-    phone = forms.CharField(label=_(\"Telefon\"), max_length=20)\n+    address = forms.CharField(label=_(\"Adresse\"), max_length=50, required=False)\n+    zip_code = forms.CharField(label=_(\"Postnummer\"), max_length=4, required=False)\n+    phone = forms.CharField(label=_(\"Telefon\"), max_length=20, required=False)\n     \n     def clean(self):\n         super(RegisterForm, self).clean()\n@@ -74,8 +74,9 @@\n \n             # ZIP code digits only\n             zip_code = cleaned_data['zip_code']\n-            if len(zip_code) != 4 or not zip_code.isdigit():\n-                self._errors['zip_code'] = self.error_class([_(u\"Postnummer m\u00e5 best\u00e5 av fire siffer.\")])\n+            if len(zip_code) != 0:\n+                if len(zip_code) != 4 or len(zip_code) != 0 or not zip_code.isdigit():\n+                    self._errors['zip_code'] = self.error_class([_(u\"Postnummer m\u00e5 best\u00e5 av fire siffer.\")])\n \n             return cleaned_data\n", "issue": "(User creation) Some fields are required that should not be\nAddress, zip and phone should not be required. People will complain.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nimport datetime\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\nfrom django.utils.translation import ugettext as _\n\nfrom apps.authentication.models import OnlineUser as User, Email\n\nclass LoginForm(forms.Form):\n    username = forms.CharField(widget=forms.TextInput(), label=_(\"Brukernavn\"), max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Passord\"))\n    user = None\n\n    def clean(self):\n        if self._errors:\n            return\n    \n        user = auth.authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])\n\n        if user:\n            if user.is_active:\n                self.user = user\n            else:\n                self._errors['username'] = self.error_class([_(u\"Din konto er ikke aktiv. Fors\u00f8k gjenoppretning av passord.\")])\n        else:\n            self._errors['username'] = self.error_class([_(u\"Kontoen eksisterer ikke, eller kombinasjonen av brukernavn og passord er feil.\")])\n        return self.cleaned_data\n\n    def login(self, request):\n        try:\n            User.objects.get(username=request.POST['username'])\n        except:\n            return False\n        if self.is_valid():\n            auth.login(request, self.user)\n            request.session.set_expiry(0)\n            return True\n        return False\n\nclass RegisterForm(forms.Form):\n    username = forms.CharField(label=_(\"Brukernavn\"), max_length=20)\n    first_name = forms.CharField(label=_(\"Fornavn\"), max_length=50)\n    last_name = forms.CharField(label=_(\"Etternavn\"), max_length=50)\n    email = forms.EmailField(label=_(\"Epost\"), max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Passord\"))\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Gjenta passord\"))\n    address = forms.CharField(label=_(\"Adresse\"), max_length=50)\n    zip_code = forms.CharField(label=_(\"Postnummer\"), max_length=4)\n    phone = forms.CharField(label=_(\"Telefon\"), max_length=20)\n    \n    def clean(self):\n        super(RegisterForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # Check passwords\n            if cleaned_data['password'] != cleaned_data['repeat_password']:\n                self._errors['repeat_password'] = self.error_class([_(u\"Passordene er ikke like.\")])\n\n            # Check username\n            username = cleaned_data['username']\n            if User.objects.filter(username=username).count() > 0:\n                self._errors['username'] = self.error_class([_(u\"Brukernavnet er allerede registrert.\")])\n            if not re.match(\"^[a-zA-Z0-9_-]+$\", username):\n                self._errors['username'] = self.error_class([_(u\"Ditt brukernavn inneholdt ulovlige tegn. Lovlige tegn: a-Z 0-9 - _\")])\n\n            # Check email\n            email = cleaned_data['email']\n            if Email.objects.filter(email=email).count() > 0:\n                self._errors['email'] = self.error_class([_(u\"Det fins allerede en bruker med denne epostadressen.\")])\n\n            # ZIP code digits only\n            zip_code = cleaned_data['zip_code']\n            if len(zip_code) != 4 or not zip_code.isdigit():\n                self._errors['zip_code'] = self.error_class([_(u\"Postnummer m\u00e5 best\u00e5 av fire siffer.\")])\n\n            return cleaned_data \n\nclass RecoveryForm(forms.Form):\n    email = forms.EmailField(label=\"Email\", max_length=50)\n\nclass ChangePasswordForm(forms.Form):\n    new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Nytt passord\"))\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Gjenta passord\"))\n\n    def clean(self):\n        super(ChangePasswordForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # Check passwords\n            if cleaned_data['new_password'] != cleaned_data['repeat_password']:\n                self._errors['repeat_password'] = self.error_class([_(u\"Passordene er ikke like.\")])\n\n            return cleaned_data\n\n\nclass NewEmailForm(forms.Form):\n    new_email = forms.EmailField(_(u\"ny epostadresse\"))\n", "path": "apps/authentication/forms.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\nimport datetime\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\nfrom django.utils.translation import ugettext as _\n\nfrom apps.authentication.models import OnlineUser as User, Email\n\nclass LoginForm(forms.Form):\n    username = forms.CharField(widget=forms.TextInput(), label=_(\"Brukernavn\"), max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Passord\"))\n    user = None\n\n    def clean(self):\n        if self._errors:\n            return\n    \n        user = auth.authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])\n\n        if user:\n            if user.is_active:\n                self.user = user\n            else:\n                self._errors['username'] = self.error_class([_(u\"Din konto er ikke aktiv. Fors\u00f8k gjenoppretning av passord.\")])\n        else:\n            self._errors['username'] = self.error_class([_(u\"Kontoen eksisterer ikke, eller kombinasjonen av brukernavn og passord er feil.\")])\n        return self.cleaned_data\n\n    def login(self, request):\n        try:\n            User.objects.get(username=request.POST['username'])\n        except:\n            return False\n        if self.is_valid():\n            auth.login(request, self.user)\n            request.session.set_expiry(0)\n            return True\n        return False\n\nclass RegisterForm(forms.Form):\n    username = forms.CharField(label=_(\"Brukernavn\"), max_length=20)\n    first_name = forms.CharField(label=_(\"Fornavn\"), max_length=50)\n    last_name = forms.CharField(label=_(\"Etternavn\"), max_length=50)\n    email = forms.EmailField(label=_(\"Epost\"), max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Passord\"))\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(\"Gjenta passord\"))\n    address = forms.CharField(label=_(\"Adresse\"), max_length=50, required=False)\n    zip_code = forms.CharField(label=_(\"Postnummer\"), max_length=4, required=False)\n    phone = forms.CharField(label=_(\"Telefon\"), max_length=20, required=False)\n    \n    def clean(self):\n        super(RegisterForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # Check passwords\n            if cleaned_data['password'] != cleaned_data['repeat_password']:\n                self._errors['repeat_password'] = self.error_class([_(u\"Passordene er ikke like.\")])\n\n            # Check username\n            username = cleaned_data['username']\n            if User.objects.filter(username=username).count() > 0:\n                self._errors['username'] = self.error_class([_(u\"Brukernavnet er allerede registrert.\")])\n            if not re.match(\"^[a-zA-Z0-9_-]+$\", username):\n                self._errors['username'] = self.error_class([_(u\"Ditt brukernavn inneholdt ulovlige tegn. Lovlige tegn: a-Z 0-9 - _\")])\n\n            # Check email\n            email = cleaned_data['email']\n            if Email.objects.filter(email=email).count() > 0:\n                self._errors['email'] = self.error_class([_(u\"Det fins allerede en bruker med denne epostadressen.\")])\n\n            # ZIP code digits only\n            zip_code = cleaned_data['zip_code']\n            if len(zip_code) != 0:\n                if len(zip_code) != 4 or len(zip_code) != 0 or not zip_code.isdigit():\n                    self._errors['zip_code'] = self.error_class([_(u\"Postnummer m\u00e5 best\u00e5 av fire siffer.\")])\n\n            return cleaned_data \n\nclass RecoveryForm(forms.Form):\n    email = forms.EmailField(label=\"Email\", max_length=50)\n\nclass ChangePasswordForm(forms.Form):\n    new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Nytt passord\"))\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=_(u\"Gjenta passord\"))\n\n    def clean(self):\n        super(ChangePasswordForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # Check passwords\n            if cleaned_data['new_password'] != cleaned_data['repeat_password']:\n                self._errors['repeat_password'] = self.error_class([_(u\"Passordene er ikke like.\")])\n\n            return cleaned_data\n\n\nclass NewEmailForm(forms.Form):\n    new_email = forms.EmailField(_(u\"ny epostadresse\"))\n", "path": "apps/authentication/forms.py"}]}