Skip to content

Commit

Permalink
feat(account): Configurable UserTokenForm
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Mar 16, 2023
1 parent b969653 commit 16be2bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
11 changes: 11 additions & 0 deletions ChangeLog.rst
@@ -1,3 +1,14 @@
0.53.0 (Unreleased)
*******************

Note worthy changes
-------------------

- You can now override the use of the ``UserTokenForm`` over at the
``PasswordResetFromKeyView`` by configuring ``ACCOUNT_FORMS["user_token"]`` to
allow the change of the password reset token generator.


0.52.0 (2022-12-29)
*******************

Expand Down
7 changes: 5 additions & 2 deletions allauth/account/views.py
Expand Up @@ -740,10 +740,13 @@ def dispatch(self, request, uidb36, key, **kwargs):
self.request = request
self.key = key

user_token_form_class = get_form_class(
app_settings.FORMS, "user_token", UserTokenForm
)
if self.key == self.reset_url_key:
self.key = self.request.session.get(INTERNAL_RESET_SESSION_KEY, "")
# (Ab)using forms here to be able to handle errors in XHR #890
token_form = UserTokenForm(data={"uidb36": uidb36, "key": self.key})
token_form = user_token_form_class(data={"uidb36": uidb36, "key": self.key})
if token_form.is_valid():
self.reset_user = token_form.reset_user

Expand All @@ -761,7 +764,7 @@ def dispatch(self, request, uidb36, key, **kwargs):
request, uidb36, self.key, **kwargs
)
else:
token_form = UserTokenForm(data={"uidb36": uidb36, "key": self.key})
token_form = user_token_form_class(data={"uidb36": uidb36, "key": self.key})
if token_form.is_valid():
# Store the key in the session and redirect to the
# password reset form at a URL without the key. That
Expand Down
9 changes: 5 additions & 4 deletions docs/forms.rst
Expand Up @@ -18,14 +18,15 @@ ACCOUNT_FORMS
Default Settings::

ACCOUNT_FORMS = {
'login': 'allauth.account.forms.LoginForm',
'signup': 'allauth.account.forms.SignupForm',
'add_email': 'allauth.account.forms.AddEmailForm',
'change_password': 'allauth.account.forms.ChangePasswordForm',
'set_password': 'allauth.account.forms.SetPasswordForm',
'disconnect': 'allauth.socialaccount.forms.DisconnectForm',
'login': 'allauth.account.forms.LoginForm',
'reset_password': 'allauth.account.forms.ResetPasswordForm',
'reset_password_from_key': 'allauth.account.forms.ResetPasswordKeyForm',
'disconnect': 'allauth.socialaccount.forms.DisconnectForm',
'set_password': 'allauth.account.forms.SetPasswordForm',
'signup': 'allauth.account.forms.SignupForm',
'user_token': 'allauth.account.forms.UserTokenForm',
}

login (``allauth.account.forms.LoginForm``)
Expand Down

0 comments on commit 16be2bd

Please sign in to comment.