We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
External authentication without second login backend enabled not possible
When using multiple authentication backends, `nav-pills` are shown shown to select the authentication method. These buttons will replace the `backend` parameter for form based authentication methods. For `authentication_url`-based backends clicking the button will redirect to an external webpage.

We exclusively use an `authentication_url`-based backend, which results in the following login screen:

![image](https://user-images.githubusercontent.com/904824/70807661-495c5100-1dbe-11ea-87b8-609770c85497.png)

Since the `nav-pills` are not rendered, we are unable to redirect to the login page.

My suggestion would be to:
1. Hide the `Log In` button when no backends are used which are submitted using form fields.
2. Always show the `nav-pills` when the only available backend uses `authentication_url` based authentication.

External authentication without second login backend enabled not possible
When using multiple authentication backends, `nav-pills` are shown shown to select the authentication method. These buttons will replace the `backend` parameter for form based authentication methods. For `authentication_url`-based backends clicking the button will redirect to an external webpage.

We exclusively use an `authentication_url`-based backend, which results in the following login screen:

![image](https://user-images.githubusercontent.com/904824/70807661-495c5100-1dbe-11ea-87b8-609770c85497.png)

Since the `nav-pills` are not rendered, we are unable to redirect to the login page.

My suggestion would be to:
1. Hide the `Log In` button when no backends are used which are submitted using form fields.
2. Always show the `nav-pills` when the only available backend uses `authentication_url` based authentication.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/pretix/base/forms/auth.py`
Content:
```
1 from django import forms
2 from django.conf import settings
3 from django.contrib.auth.password_validation import (
4     password_validators_help_texts, validate_password,
5 )
6 from django.utils.translation import ugettext_lazy as _
7 
8 from pretix.base.models import User
9 
10 
11 class LoginForm(forms.Form):
12     """
13     Base class for authenticating users. Extend this to get a form that accepts
14     username/password logins.
15     """
16     keep_logged_in = forms.BooleanField(label=_("Keep me logged in"), required=False)
17 
18     error_messages = {
19         'invalid_login': _("This combination of credentials is not known to our system."),
20         'inactive': _("This account is inactive.")
21     }
22 
23     def __init__(self, backend, request=None, *args, **kwargs):
24         """
25         The 'request' parameter is set for custom auth use by subclasses.
26         The form data comes in via the standard 'data' kwarg.
27         """
28         self.request = request
29         self.user_cache = None
30         self.backend = backend
31         super().__init__(*args, **kwargs)
32         for k, f in backend.login_form_fields.items():
33             self.fields[k] = f
34 
35         if not settings.PRETIX_LONG_SESSIONS:
36             del self.fields['keep_logged_in']
37         else:
38             self.fields.move_to_end('keep_logged_in')
39 
40     def clean(self):
41         if all(k in self.cleaned_data for k, f in self.fields.items() if f.required):
42             self.user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)
43             if self.user_cache is None:
44                 raise forms.ValidationError(
45                     self.error_messages['invalid_login'],
46                     code='invalid_login'
47                 )
48             else:
49                 self.confirm_login_allowed(self.user_cache)
50 
51         return self.cleaned_data
52 
53     def confirm_login_allowed(self, user: User):
54         """
55         Controls whether the given User may log in. This is a policy setting,
56         independent of end-user authentication. This default behavior is to
57         allow login by active users, and reject login by inactive users.
58 
59         If the given user cannot log in, this method should raise a
60         ``forms.ValidationError``.
61 
62         If the given user may log in, this method should return None.
63         """
64         if not user.is_active:
65             raise forms.ValidationError(
66                 self.error_messages['inactive'],
67                 code='inactive',
68             )
69 
70     def get_user(self):
71         return self.user_cache
72 
73 
74 class RegistrationForm(forms.Form):
75     error_messages = {
76         'duplicate_email': _("You already registered with that email address, please use the login form."),
77         'pw_mismatch': _("Please enter the same password twice"),
78     }
79     email = forms.EmailField(
80         label=_('Email address'),
81         required=True
82     )
83     password = forms.CharField(
84         label=_('Password'),
85         widget=forms.PasswordInput(attrs={
86             'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7
87         }),
88         required=True
89     )
90     password_repeat = forms.CharField(
91         label=_('Repeat password'),
92         widget=forms.PasswordInput(attrs={
93             'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7
94         }),
95         required=True
96     )
97     keep_logged_in = forms.BooleanField(label=_("Keep me logged in"), required=False)
98 
99     def __init__(self, *args, **kwargs):
100         super().__init__(*args, **kwargs)
101         if not settings.PRETIX_LONG_SESSIONS:
102             del self.fields['keep_logged_in']
103 
104     def clean(self):
105         password1 = self.cleaned_data.get('password', '')
106         password2 = self.cleaned_data.get('password_repeat')
107 
108         if password1 and password1 != password2:
109             raise forms.ValidationError({
110                 'password_repeat': self.error_messages['pw_mismatch'],
111             }, code='pw_mismatch')
112         return self.cleaned_data
113 
114     def clean_password(self):
115         password1 = self.cleaned_data.get('password', '')
116         user = User(email=self.cleaned_data.get('email'))
117         if validate_password(password1, user=user) is not None:
118             raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')
119         return password1
120 
121     def clean_email(self):
122         email = self.cleaned_data['email']
123         if User.objects.filter(email__iexact=email).exists():
124             raise forms.ValidationError(
125                 self.error_messages['duplicate_email'],
126                 code='duplicate_email'
127             )
128         return email
129 
130 
131 class PasswordRecoverForm(forms.Form):
132     error_messages = {
133         'pw_mismatch': _("Please enter the same password twice"),
134     }
135     password = forms.CharField(
136         label=_('Password'),
137         widget=forms.PasswordInput,
138         required=True
139     )
140     password_repeat = forms.CharField(
141         label=_('Repeat password'),
142         widget=forms.PasswordInput
143     )
144 
145     def __init__(self, user_id=None, *args, **kwargs):
146         self.user_id = user_id
147         super().__init__(*args, **kwargs)
148 
149     def clean(self):
150         password1 = self.cleaned_data.get('password', '')
151         password2 = self.cleaned_data.get('password_repeat')
152 
153         if password1 and password1 != password2:
154             raise forms.ValidationError({
155                 'password_repeat': self.error_messages['pw_mismatch'],
156             }, code='pw_mismatch')
157 
158         return self.cleaned_data
159 
160     def clean_password(self):
161         password1 = self.cleaned_data.get('password', '')
162         try:
163             user = User.objects.get(id=self.user_id)
164         except User.DoesNotExist:
165             user = None
166         if validate_password(password1, user=user) is not None:
167             raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')
168         return password1
169 
170 
171 class PasswordForgotForm(forms.Form):
172     email = forms.EmailField(
173         label=_('E-mail'),
174     )
175 
176     def __init__(self, *args, **kwargs):
177         if 'event' in kwargs:
178             # Backwards compatibility
179             del kwargs['event']
180         super().__init__(*args, **kwargs)
181 
182     def clean_email(self):
183         return self.cleaned_data['email']
184 
185 
186 class ReauthForm(forms.Form):
187     error_messages = {
188         'invalid_login': _("This combination of credentials is not known to our system."),
189         'inactive': _("This account is inactive.")
190     }
191 
192     def __init__(self, backend, user, request=None, *args, **kwargs):
193         """
194         The 'request' parameter is set for custom auth use by subclasses.
195         The form data comes in via the standard 'data' kwarg.
196         """
197         self.request = request
198         self.user = user
199         self.backend = backend
200         super().__init__(*args, **kwargs)
201         for k, f in backend.login_form_fields.items():
202             self.fields[k] = f
203         if 'email' in self.fields:
204             self.fields['email'].disabled = True
205 
206     def clean(self):
207         self.cleaned_data['email'] = self.user.email
208         user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)
209         if user_cache != self.user:
210             raise forms.ValidationError(
211                 self.error_messages['invalid_login'],
212                 code='invalid_login'
213             )
214         else:
215             self.confirm_login_allowed(user_cache)
216 
217         return self.cleaned_data
218 
219     def confirm_login_allowed(self, user: User):
220         if not user.is_active:
221             raise forms.ValidationError(
222                 self.error_messages['inactive'],
223                 code='inactive',
224             )
225
```
--- 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/src/pretix/base/forms/auth.py b/src/pretix/base/forms/auth.py
--- a/src/pretix/base/forms/auth.py
+++ b/src/pretix/base/forms/auth.py
@@ -32,7 +32,8 @@
         for k, f in backend.login_form_fields.items():
             self.fields[k] = f
 
-        if not settings.PRETIX_LONG_SESSIONS:
+        # Authentication backends which use urls cannot have long sessions.
+        if not settings.PRETIX_LONG_SESSIONS or backend.url:
             del self.fields['keep_logged_in']
         else:
             self.fields.move_to_end('keep_logged_in')

{"golden_diff": "diff --git a/src/pretix/base/forms/auth.py b/src/pretix/base/forms/auth.py\n--- a/src/pretix/base/forms/auth.py\n+++ b/src/pretix/base/forms/auth.py\n@@ -32,7 +32,8 @@\n         for k, f in backend.login_form_fields.items():\n             self.fields[k] = f\n \n-        if not settings.PRETIX_LONG_SESSIONS:\n+        # Authentication backends which use urls cannot have long sessions.\n+        if not settings.PRETIX_LONG_SESSIONS or backend.url:\n             del self.fields['keep_logged_in']\n         else:\n             self.fields.move_to_end('keep_logged_in')\n", "issue": "External authentication without second login backend enabled not possible\nWhen using multiple authentication backends, `nav-pills` are shown shown to select the authentication method. These buttons will replace the `backend` parameter for form based authentication methods. For `authentication_url`-based backends clicking the button will redirect to an external webpage.\r\n\r\nWe exclusively use an `authentication_url`-based backend, which results in the following login screen:\r\n\r\n![image](https://user-images.githubusercontent.com/904824/70807661-495c5100-1dbe-11ea-87b8-609770c85497.png)\r\n\r\nSince the `nav-pills` are not rendered, we are unable to redirect to the login page.\r\n\r\nMy suggestion would be to:\r\n1. Hide the `Log In` button when no backends are used which are submitted using form fields.\r\n2. Always show the `nav-pills` when the only available backend uses `authentication_url` based authentication.\r\n\nExternal authentication without second login backend enabled not possible\nWhen using multiple authentication backends, `nav-pills` are shown shown to select the authentication method. These buttons will replace the `backend` parameter for form based authentication methods. For `authentication_url`-based backends clicking the button will redirect to an external webpage.\r\n\r\nWe exclusively use an `authentication_url`-based backend, which results in the following login screen:\r\n\r\n![image](https://user-images.githubusercontent.com/904824/70807661-495c5100-1dbe-11ea-87b8-609770c85497.png)\r\n\r\nSince the `nav-pills` are not rendered, we are unable to redirect to the login page.\r\n\r\nMy suggestion would be to:\r\n1. Hide the `Log In` button when no backends are used which are submitted using form fields.\r\n2. Always show the `nav-pills` when the only available backend uses `authentication_url` based authentication.\r\n\n", "before_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.contrib.auth.password_validation import (\n    password_validators_help_texts, validate_password,\n)\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom pretix.base.models import User\n\n\nclass LoginForm(forms.Form):\n    \"\"\"\n    Base class for authenticating users. Extend this to get a form that accepts\n    username/password logins.\n    \"\"\"\n    keep_logged_in = forms.BooleanField(label=_(\"Keep me logged in\"), required=False)\n\n    error_messages = {\n        'invalid_login': _(\"This combination of credentials is not known to our system.\"),\n        'inactive': _(\"This account is inactive.\")\n    }\n\n    def __init__(self, backend, request=None, *args, **kwargs):\n        \"\"\"\n        The 'request' parameter is set for custom auth use by subclasses.\n        The form data comes in via the standard 'data' kwarg.\n        \"\"\"\n        self.request = request\n        self.user_cache = None\n        self.backend = backend\n        super().__init__(*args, **kwargs)\n        for k, f in backend.login_form_fields.items():\n            self.fields[k] = f\n\n        if not settings.PRETIX_LONG_SESSIONS:\n            del self.fields['keep_logged_in']\n        else:\n            self.fields.move_to_end('keep_logged_in')\n\n    def clean(self):\n        if all(k in self.cleaned_data for k, f in self.fields.items() if f.required):\n            self.user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)\n            if self.user_cache is None:\n                raise forms.ValidationError(\n                    self.error_messages['invalid_login'],\n                    code='invalid_login'\n                )\n            else:\n                self.confirm_login_allowed(self.user_cache)\n\n        return self.cleaned_data\n\n    def confirm_login_allowed(self, user: User):\n        \"\"\"\n        Controls whether the given User may log in. This is a policy setting,\n        independent of end-user authentication. This default behavior is to\n        allow login by active users, and reject login by inactive users.\n\n        If the given user cannot log in, this method should raise a\n        ``forms.ValidationError``.\n\n        If the given user may log in, this method should return None.\n        \"\"\"\n        if not user.is_active:\n            raise forms.ValidationError(\n                self.error_messages['inactive'],\n                code='inactive',\n            )\n\n    def get_user(self):\n        return self.user_cache\n\n\nclass RegistrationForm(forms.Form):\n    error_messages = {\n        'duplicate_email': _(\"You already registered with that email address, please use the login form.\"),\n        'pw_mismatch': _(\"Please enter the same password twice\"),\n    }\n    email = forms.EmailField(\n        label=_('Email address'),\n        required=True\n    )\n    password = forms.CharField(\n        label=_('Password'),\n        widget=forms.PasswordInput(attrs={\n            'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7\n        }),\n        required=True\n    )\n    password_repeat = forms.CharField(\n        label=_('Repeat password'),\n        widget=forms.PasswordInput(attrs={\n            'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7\n        }),\n        required=True\n    )\n    keep_logged_in = forms.BooleanField(label=_(\"Keep me logged in\"), required=False)\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if not settings.PRETIX_LONG_SESSIONS:\n            del self.fields['keep_logged_in']\n\n    def clean(self):\n        password1 = self.cleaned_data.get('password', '')\n        password2 = self.cleaned_data.get('password_repeat')\n\n        if password1 and password1 != password2:\n            raise forms.ValidationError({\n                'password_repeat': self.error_messages['pw_mismatch'],\n            }, code='pw_mismatch')\n        return self.cleaned_data\n\n    def clean_password(self):\n        password1 = self.cleaned_data.get('password', '')\n        user = User(email=self.cleaned_data.get('email'))\n        if validate_password(password1, user=user) is not None:\n            raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')\n        return password1\n\n    def clean_email(self):\n        email = self.cleaned_data['email']\n        if User.objects.filter(email__iexact=email).exists():\n            raise forms.ValidationError(\n                self.error_messages['duplicate_email'],\n                code='duplicate_email'\n            )\n        return email\n\n\nclass PasswordRecoverForm(forms.Form):\n    error_messages = {\n        'pw_mismatch': _(\"Please enter the same password twice\"),\n    }\n    password = forms.CharField(\n        label=_('Password'),\n        widget=forms.PasswordInput,\n        required=True\n    )\n    password_repeat = forms.CharField(\n        label=_('Repeat password'),\n        widget=forms.PasswordInput\n    )\n\n    def __init__(self, user_id=None, *args, **kwargs):\n        self.user_id = user_id\n        super().__init__(*args, **kwargs)\n\n    def clean(self):\n        password1 = self.cleaned_data.get('password', '')\n        password2 = self.cleaned_data.get('password_repeat')\n\n        if password1 and password1 != password2:\n            raise forms.ValidationError({\n                'password_repeat': self.error_messages['pw_mismatch'],\n            }, code='pw_mismatch')\n\n        return self.cleaned_data\n\n    def clean_password(self):\n        password1 = self.cleaned_data.get('password', '')\n        try:\n            user = User.objects.get(id=self.user_id)\n        except User.DoesNotExist:\n            user = None\n        if validate_password(password1, user=user) is not None:\n            raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')\n        return password1\n\n\nclass PasswordForgotForm(forms.Form):\n    email = forms.EmailField(\n        label=_('E-mail'),\n    )\n\n    def __init__(self, *args, **kwargs):\n        if 'event' in kwargs:\n            # Backwards compatibility\n            del kwargs['event']\n        super().__init__(*args, **kwargs)\n\n    def clean_email(self):\n        return self.cleaned_data['email']\n\n\nclass ReauthForm(forms.Form):\n    error_messages = {\n        'invalid_login': _(\"This combination of credentials is not known to our system.\"),\n        'inactive': _(\"This account is inactive.\")\n    }\n\n    def __init__(self, backend, user, request=None, *args, **kwargs):\n        \"\"\"\n        The 'request' parameter is set for custom auth use by subclasses.\n        The form data comes in via the standard 'data' kwarg.\n        \"\"\"\n        self.request = request\n        self.user = user\n        self.backend = backend\n        super().__init__(*args, **kwargs)\n        for k, f in backend.login_form_fields.items():\n            self.fields[k] = f\n        if 'email' in self.fields:\n            self.fields['email'].disabled = True\n\n    def clean(self):\n        self.cleaned_data['email'] = self.user.email\n        user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)\n        if user_cache != self.user:\n            raise forms.ValidationError(\n                self.error_messages['invalid_login'],\n                code='invalid_login'\n            )\n        else:\n            self.confirm_login_allowed(user_cache)\n\n        return self.cleaned_data\n\n    def confirm_login_allowed(self, user: User):\n        if not user.is_active:\n            raise forms.ValidationError(\n                self.error_messages['inactive'],\n                code='inactive',\n            )\n", "path": "src/pretix/base/forms/auth.py"}], "after_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.contrib.auth.password_validation import (\n    password_validators_help_texts, validate_password,\n)\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom pretix.base.models import User\n\n\nclass LoginForm(forms.Form):\n    \"\"\"\n    Base class for authenticating users. Extend this to get a form that accepts\n    username/password logins.\n    \"\"\"\n    keep_logged_in = forms.BooleanField(label=_(\"Keep me logged in\"), required=False)\n\n    error_messages = {\n        'invalid_login': _(\"This combination of credentials is not known to our system.\"),\n        'inactive': _(\"This account is inactive.\")\n    }\n\n    def __init__(self, backend, request=None, *args, **kwargs):\n        \"\"\"\n        The 'request' parameter is set for custom auth use by subclasses.\n        The form data comes in via the standard 'data' kwarg.\n        \"\"\"\n        self.request = request\n        self.user_cache = None\n        self.backend = backend\n        super().__init__(*args, **kwargs)\n        for k, f in backend.login_form_fields.items():\n            self.fields[k] = f\n\n        # Authentication backends which use urls cannot have long sessions.\n        if not settings.PRETIX_LONG_SESSIONS or backend.url:\n            del self.fields['keep_logged_in']\n        else:\n            self.fields.move_to_end('keep_logged_in')\n\n    def clean(self):\n        if all(k in self.cleaned_data for k, f in self.fields.items() if f.required):\n            self.user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)\n            if self.user_cache is None:\n                raise forms.ValidationError(\n                    self.error_messages['invalid_login'],\n                    code='invalid_login'\n                )\n            else:\n                self.confirm_login_allowed(self.user_cache)\n\n        return self.cleaned_data\n\n    def confirm_login_allowed(self, user: User):\n        \"\"\"\n        Controls whether the given User may log in. This is a policy setting,\n        independent of end-user authentication. This default behavior is to\n        allow login by active users, and reject login by inactive users.\n\n        If the given user cannot log in, this method should raise a\n        ``forms.ValidationError``.\n\n        If the given user may log in, this method should return None.\n        \"\"\"\n        if not user.is_active:\n            raise forms.ValidationError(\n                self.error_messages['inactive'],\n                code='inactive',\n            )\n\n    def get_user(self):\n        return self.user_cache\n\n\nclass RegistrationForm(forms.Form):\n    error_messages = {\n        'duplicate_email': _(\"You already registered with that email address, please use the login form.\"),\n        'pw_mismatch': _(\"Please enter the same password twice\"),\n    }\n    email = forms.EmailField(\n        label=_('Email address'),\n        required=True\n    )\n    password = forms.CharField(\n        label=_('Password'),\n        widget=forms.PasswordInput(attrs={\n            'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7\n        }),\n        required=True\n    )\n    password_repeat = forms.CharField(\n        label=_('Repeat password'),\n        widget=forms.PasswordInput(attrs={\n            'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7\n        }),\n        required=True\n    )\n    keep_logged_in = forms.BooleanField(label=_(\"Keep me logged in\"), required=False)\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        if not settings.PRETIX_LONG_SESSIONS:\n            del self.fields['keep_logged_in']\n\n    def clean(self):\n        password1 = self.cleaned_data.get('password', '')\n        password2 = self.cleaned_data.get('password_repeat')\n\n        if password1 and password1 != password2:\n            raise forms.ValidationError({\n                'password_repeat': self.error_messages['pw_mismatch'],\n            }, code='pw_mismatch')\n        return self.cleaned_data\n\n    def clean_password(self):\n        password1 = self.cleaned_data.get('password', '')\n        user = User(email=self.cleaned_data.get('email'))\n        if validate_password(password1, user=user) is not None:\n            raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')\n        return password1\n\n    def clean_email(self):\n        email = self.cleaned_data['email']\n        if User.objects.filter(email__iexact=email).exists():\n            raise forms.ValidationError(\n                self.error_messages['duplicate_email'],\n                code='duplicate_email'\n            )\n        return email\n\n\nclass PasswordRecoverForm(forms.Form):\n    error_messages = {\n        'pw_mismatch': _(\"Please enter the same password twice\"),\n    }\n    password = forms.CharField(\n        label=_('Password'),\n        widget=forms.PasswordInput,\n        required=True\n    )\n    password_repeat = forms.CharField(\n        label=_('Repeat password'),\n        widget=forms.PasswordInput\n    )\n\n    def __init__(self, user_id=None, *args, **kwargs):\n        self.user_id = user_id\n        super().__init__(*args, **kwargs)\n\n    def clean(self):\n        password1 = self.cleaned_data.get('password', '')\n        password2 = self.cleaned_data.get('password_repeat')\n\n        if password1 and password1 != password2:\n            raise forms.ValidationError({\n                'password_repeat': self.error_messages['pw_mismatch'],\n            }, code='pw_mismatch')\n\n        return self.cleaned_data\n\n    def clean_password(self):\n        password1 = self.cleaned_data.get('password', '')\n        try:\n            user = User.objects.get(id=self.user_id)\n        except User.DoesNotExist:\n            user = None\n        if validate_password(password1, user=user) is not None:\n            raise forms.ValidationError(_(password_validators_help_texts()), code='pw_invalid')\n        return password1\n\n\nclass PasswordForgotForm(forms.Form):\n    email = forms.EmailField(\n        label=_('E-mail'),\n    )\n\n    def __init__(self, *args, **kwargs):\n        if 'event' in kwargs:\n            # Backwards compatibility\n            del kwargs['event']\n        super().__init__(*args, **kwargs)\n\n    def clean_email(self):\n        return self.cleaned_data['email']\n\n\nclass ReauthForm(forms.Form):\n    error_messages = {\n        'invalid_login': _(\"This combination of credentials is not known to our system.\"),\n        'inactive': _(\"This account is inactive.\")\n    }\n\n    def __init__(self, backend, user, request=None, *args, **kwargs):\n        \"\"\"\n        The 'request' parameter is set for custom auth use by subclasses.\n        The form data comes in via the standard 'data' kwarg.\n        \"\"\"\n        self.request = request\n        self.user = user\n        self.backend = backend\n        super().__init__(*args, **kwargs)\n        for k, f in backend.login_form_fields.items():\n            self.fields[k] = f\n        if 'email' in self.fields:\n            self.fields['email'].disabled = True\n\n    def clean(self):\n        self.cleaned_data['email'] = self.user.email\n        user_cache = self.backend.form_authenticate(self.request, self.cleaned_data)\n        if user_cache != self.user:\n            raise forms.ValidationError(\n                self.error_messages['invalid_login'],\n                code='invalid_login'\n            )\n        else:\n            self.confirm_login_allowed(user_cache)\n\n        return self.cleaned_data\n\n    def confirm_login_allowed(self, user: User):\n        if not user.is_active:\n            raise forms.ValidationError(\n                self.error_messages['inactive'],\n                code='inactive',\n            )\n", "path": "src/pretix/base/forms/auth.py"}]}