|
1 |
| -from importlib import import_module |
2 | 1 | from typing import Optional
|
3 | 2 |
|
4 | 3 | from django import forms
|
|
17 | 16 |
|
18 | 17 | from allauth.account.app_settings import LoginMethod
|
19 | 18 | from allauth.account.internal import flows
|
| 19 | +from allauth.account.internal.flows.signup import base_signup_form_class |
20 | 20 | from allauth.account.internal.stagekit import LOGIN_SESSION_KEY
|
21 | 21 | from allauth.account.internal.textkit import compare_code
|
22 | 22 | from allauth.account.stages import EmailVerificationStage
|
@@ -279,55 +279,7 @@ def _login_with_password(self, request, redirect_url, credentials):
|
279 | 279 | return ret
|
280 | 280 |
|
281 | 281 |
|
282 |
| -class _DummyCustomSignupForm(forms.Form): |
283 |
| - def signup(self, request, user): |
284 |
| - """ |
285 |
| - Invoked at signup time to complete the signup of the user. |
286 |
| - """ |
287 |
| - pass |
288 |
| - |
289 |
| - |
290 |
| -def _base_signup_form_class(): |
291 |
| - """ |
292 |
| - Currently, we inherit from the custom form, if any. This is all |
293 |
| - not very elegant, though it serves a purpose: |
294 |
| -
|
295 |
| - - There are two signup forms: one for local accounts, and one for |
296 |
| - social accounts |
297 |
| - - Both share a common base (BaseSignupForm) |
298 |
| -
|
299 |
| - - Given the above, how to put in a custom signup form? Which form |
300 |
| - would your custom form derive from, the local or the social one? |
301 |
| - """ |
302 |
| - if not app_settings.SIGNUP_FORM_CLASS: |
303 |
| - return _DummyCustomSignupForm |
304 |
| - try: |
305 |
| - fc_module, fc_classname = app_settings.SIGNUP_FORM_CLASS.rsplit(".", 1) |
306 |
| - except ValueError: |
307 |
| - raise exceptions.ImproperlyConfigured( |
308 |
| - "%s does not point to a form class" % app_settings.SIGNUP_FORM_CLASS |
309 |
| - ) |
310 |
| - try: |
311 |
| - mod = import_module(fc_module) |
312 |
| - except ImportError as e: |
313 |
| - raise exceptions.ImproperlyConfigured( |
314 |
| - "Error importing form class %s:" ' "%s"' % (fc_module, e) |
315 |
| - ) |
316 |
| - try: |
317 |
| - fc_class = getattr(mod, fc_classname) |
318 |
| - except AttributeError: |
319 |
| - raise exceptions.ImproperlyConfigured( |
320 |
| - 'Module "%s" does not define a' ' "%s" class' % (fc_module, fc_classname) |
321 |
| - ) |
322 |
| - if not hasattr(fc_class, "signup"): |
323 |
| - raise exceptions.ImproperlyConfigured( |
324 |
| - "The custom signup form must offer" |
325 |
| - " a `def signup(self, request, user)` method", |
326 |
| - ) |
327 |
| - return fc_class |
328 |
| - |
329 |
| - |
330 |
| -class BaseSignupForm(_base_signup_form_class()): # type: ignore[misc] |
| 282 | +class BaseSignupForm(base_signup_form_class()): # type: ignore[misc] |
331 | 283 | username = forms.CharField(
|
332 | 284 | label=_("Username"),
|
333 | 285 | min_length=app_settings.USERNAME_MIN_LENGTH,
|
|
0 commit comments