prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Auth templates does not use crispy forms
  https://github.com/dotKom/onlineweb4/commit/26ae7847c2907895e6842061a848a2c0f47090a0
  
  Håvard did some weird shit. Undo this and test that it still works.
  
  
  --- 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/urls.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 from django.conf.urls import patterns, url
  4 
  5 urlpatterns = patterns('apps.authentication.views',
  6     url(r'^login/$', 'login', name='auth_login'),
  7     url(r'^logout/$', 'logout', name='auth_logout'),
  8     url(r'^register/$', 'register', name='auth_register'),
  9     url(r'^verify/(\w+)/$', 'verify', name='auth_verify'),
  10     url(r'^recover/$', 'recover', name='auth_recover'),
  11     url(r'^set_password/(\w+)/$', 'set_password', name='auth_set_password'),
  12 )
  13
  ```
  
  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 
  9 from apps.authentication.models import OnlineUser as User
  10 
  11 class LoginForm(forms.Form):
  12     username = forms.CharField(widget=forms.TextInput(), label="Username", max_length=50)
  13     password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Password")
  14     user = None
  15 
  16     def clean(self):
  17         if self._errors:
  18             return
  19     
  20         user = auth.authenticate(username=self.cleaned_data['username'], password=self.cleaned_data['password'])
  21 
  22         if user:
  23             if user.is_active:
  24                 self.user = user
  25             else:
  26                 self._errors['username'] = self.error_class(["Your account is inactive, try to recover it."])
  27         else:
  28             self._errors['username'] = self.error_class(["The account does not exist, or username/password combination is incorrect."])
  29         return self.cleaned_data
  30 
  31     def login(self, request):
  32         try:
  33             User.objects.get(username=request.POST['username'])
  34         except:
  35             return False
  36         if self.is_valid():
  37             auth.login(request, self.user)
  38             request.session.set_expiry(0)
  39             return True
  40         return False
  41 
  42 class RegisterForm(forms.Form):
  43     username = forms.CharField(label="Username", max_length=20)
  44     first_name = forms.CharField(label="First name", max_length=50)
  45     last_name = forms.CharField(label="Last name", max_length=50)
  46     email = forms.EmailField(label="Email", max_length=50)
  47     password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Password")
  48     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Repeat password")
  49     address = forms.CharField(label="Address", max_length=50)
  50     zip_code = forms.CharField(label="ZIP code", max_length=4)
  51     phone = forms.CharField(label="Phone number", max_length=20)
  52     
  53     def clean(self):
  54         super(RegisterForm, self).clean()
  55         if self.is_valid():
  56             cleaned_data = self.cleaned_data
  57 
  58             # Check passwords
  59             if cleaned_data['password'] != cleaned_data['repeat_password']:
  60                 self._errors['repeat_password'] = self.error_class(["Passwords did not match."])
  61 
  62             # Check username
  63             username = cleaned_data['username']
  64             if User.objects.filter(username=username).count() > 0:
  65                 self._errors['username'] = self.error_class(["There is already a user with that username."])
  66             if not re.match("^[a-zA-Z0-9_-]+$", username):
  67                 self._errors['username'] = self.error_class(["Your desired username contains illegal characters. Valid: a-Z 0-9 - _"])
  68 
  69             # Check email
  70             email = cleaned_data['email']
  71             if User.objects.filter(email=email).count() > 0:
  72                 self._errors['email'] = self.error_class(["There is already a user with that email."])
  73 
  74             # ZIP code digits only
  75             zip_code = cleaned_data['zip_code']
  76             if len(zip_code) != 4 or not zip_code.isdigit():
  77                 self._errors['zip_code'] = self.error_class(["The ZIP code must be 4 digit number."])
  78 
  79             return cleaned_data 
  80 
  81 class RecoveryForm(forms.Form):
  82     email = forms.EmailField(label="Email", max_length=50)
  83 
  84 class ChangePasswordForm(forms.Form):
  85     old_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Old password", required=False)
  86     new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="New password")
  87     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Repeat new password")
  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(["Passwords did not match."])
  97 
  98             return cleaned_data
  99
  ```
  --- 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
  @@ -82,7 +82,6 @@
       email = forms.EmailField(label="Email", max_length=50)
   
   class ChangePasswordForm(forms.Form):
  -    old_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Old password", required=False)
       new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="New password")
       repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label="Repeat new password")
   
  diff --git a/apps/authentication/urls.py b/apps/authentication/urls.py
  --- a/apps/authentication/urls.py
  +++ b/apps/authentication/urls.py
  @@ -6,7 +6,7 @@
       url(r'^login/$', 'login', name='auth_login'),
       url(r'^logout/$', 'logout', name='auth_logout'),
       url(r'^register/$', 'register', name='auth_register'),
  -    url(r'^verify/(\w+)/$', 'verify', name='auth_verify'),
  +    url(r'^verify/(?P<token>\w+)/$', 'verify', name='auth_verify'),
       url(r'^recover/$', 'recover', name='auth_recover'),
  -    url(r'^set_password/(\w+)/$', 'set_password', name='auth_set_password'),
  +    url(r'^set_password/(?P<token>\w+)/$', 'set_password', name='auth_set_password'),
   )
  
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@@ -82,7 +82,6 @@\n     email = forms.EmailField(label=\"Email\", max_length=50)\n \n class ChangePasswordForm(forms.Form):\n-    old_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Old password\", required=False)\n     new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"New password\")\n     repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Repeat new password\")\n \ndiff --git a/apps/authentication/urls.py b/apps/authentication/urls.py\n--- a/apps/authentication/urls.py\n+++ b/apps/authentication/urls.py\n@@ -6,7 +6,7 @@\n     url(r'^login/$', 'login', name='auth_login'),\n     url(r'^logout/$', 'logout', name='auth_logout'),\n     url(r'^register/$', 'register', name='auth_register'),\n-    url(r'^verify/(\\w+)/$', 'verify', name='auth_verify'),\n+    url(r'^verify/(?P<token>\\w+)/$', 'verify', name='auth_verify'),\n     url(r'^recover/$', 'recover', name='auth_recover'),\n-    url(r'^set_password/(\\w+)/$', 'set_password', name='auth_set_password'),\n+    url(r'^set_password/(?P<token>\\w+)/$', 'set_password', name='auth_set_password'),\n )\n", "issue": "Auth templates does not use crispy forms\nhttps://github.com/dotKom/onlineweb4/commit/26ae7847c2907895e6842061a848a2c0f47090a0\n\nH\u00e5vard did some weird shit. Undo this and test that it still works.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom django.conf.urls import patterns, url\n\nurlpatterns = patterns('apps.authentication.views',\n    url(r'^login/$', 'login', name='auth_login'),\n    url(r'^logout/$', 'logout', name='auth_logout'),\n    url(r'^register/$', 'register', name='auth_register'),\n    url(r'^verify/(\\w+)/$', 'verify', name='auth_verify'),\n    url(r'^recover/$', 'recover', name='auth_recover'),\n    url(r'^set_password/(\\w+)/$', 'set_password', name='auth_set_password'),\n)\n", "path": "apps/authentication/urls.py"}, {"content": "# -*- coding: utf-8 -*-\n\nimport datetime\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\n\nfrom apps.authentication.models import OnlineUser as User\n\nclass LoginForm(forms.Form):\n    username = forms.CharField(widget=forms.TextInput(), label=\"Username\", max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Password\")\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([\"Your account is inactive, try to recover it.\"])\n        else:\n            self._errors['username'] = self.error_class([\"The account does not exist, or username/password combination is incorrect.\"])\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=\"Username\", max_length=20)\n    first_name = forms.CharField(label=\"First name\", max_length=50)\n    last_name = forms.CharField(label=\"Last name\", max_length=50)\n    email = forms.EmailField(label=\"Email\", max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Password\")\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Repeat password\")\n    address = forms.CharField(label=\"Address\", max_length=50)\n    zip_code = forms.CharField(label=\"ZIP code\", max_length=4)\n    phone = forms.CharField(label=\"Phone number\", 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([\"Passwords did not match.\"])\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([\"There is already a user with that username.\"])\n            if not re.match(\"^[a-zA-Z0-9_-]+$\", username):\n                self._errors['username'] = self.error_class([\"Your desired username contains illegal characters. Valid: a-Z 0-9 - _\"])\n\n            # Check email\n            email = cleaned_data['email']\n            if User.objects.filter(email=email).count() > 0:\n                self._errors['email'] = self.error_class([\"There is already a user with that email.\"])\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([\"The ZIP code must be 4 digit number.\"])\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    old_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Old password\", required=False)\n    new_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"New password\")\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Repeat new password\")\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([\"Passwords did not match.\"])\n\n            return cleaned_data\n", "path": "apps/authentication/forms.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\nfrom django.conf.urls import patterns, url\n\nurlpatterns = patterns('apps.authentication.views',\n    url(r'^login/$', 'login', name='auth_login'),\n    url(r'^logout/$', 'logout', name='auth_logout'),\n    url(r'^register/$', 'register', name='auth_register'),\n    url(r'^verify/(?P<token>\\w+)/$', 'verify', name='auth_verify'),\n    url(r'^recover/$', 'recover', name='auth_recover'),\n    url(r'^set_password/(?P<token>\\w+)/$', 'set_password', name='auth_set_password'),\n)\n", "path": "apps/authentication/urls.py"}, {"content": "# -*- coding: utf-8 -*-\n\nimport datetime\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\n\nfrom apps.authentication.models import OnlineUser as User\n\nclass LoginForm(forms.Form):\n    username = forms.CharField(widget=forms.TextInput(), label=\"Username\", max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Password\")\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([\"Your account is inactive, try to recover it.\"])\n        else:\n            self._errors['username'] = self.error_class([\"The account does not exist, or username/password combination is incorrect.\"])\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=\"Username\", max_length=20)\n    first_name = forms.CharField(label=\"First name\", max_length=50)\n    last_name = forms.CharField(label=\"Last name\", max_length=50)\n    email = forms.EmailField(label=\"Email\", max_length=50)\n    password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Password\")\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Repeat password\")\n    address = forms.CharField(label=\"Address\", max_length=50)\n    zip_code = forms.CharField(label=\"ZIP code\", max_length=4)\n    phone = forms.CharField(label=\"Phone number\", 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([\"Passwords did not match.\"])\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([\"There is already a user with that username.\"])\n            if not re.match(\"^[a-zA-Z0-9_-]+$\", username):\n                self._errors['username'] = self.error_class([\"Your desired username contains illegal characters. Valid: a-Z 0-9 - _\"])\n\n            # Check email\n            email = cleaned_data['email']\n            if User.objects.filter(email=email).count() > 0:\n                self._errors['email'] = self.error_class([\"There is already a user with that email.\"])\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([\"The ZIP code must be 4 digit number.\"])\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=\"New password\")\n    repeat_password = forms.CharField(widget=forms.PasswordInput(render_value=False), label=\"Repeat new password\")\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([\"Passwords did not match.\"])\n\n            return cleaned_data\n", "path": "apps/authentication/forms.py"}]}