Skip to content

Commit

Permalink
fix(account): verify by code: get_email_verification_redirect_url()
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Nov 1, 2024
1 parent c6b16ae commit 7fedd13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Fixes
``LoginRequiredMiddleware``, as it was not properly marked as
``@login_not_required``.

- When verifying an email address by code, the success URL was hardcoded to the
email management view, instead of calling the
``get_email_verification_redirect_url()`` adapter method.


65.1.0 (2024-10-23)
*******************
Expand Down
2 changes: 1 addition & 1 deletion allauth/account/tests/test_email_verification_by_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_add_or_change_email(auth_client, user, get_last_code, change_email, set
reverse("account_email_verification_sent"), data={"code": code}
)
assert resp.status_code == 302
assert resp["location"] == reverse("account_email")
assert resp["location"] == settings.LOGIN_REDIRECT_URL
assert email_added_signal.send.called
assert email_confirmed_signal.send.called
assert email_changed_signal.send.called == change_email
Expand Down
8 changes: 7 additions & 1 deletion allauth/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,13 @@ def form_valid(self, form):
if not email_address:
return self.stage.abort()
return self.stage.exit()
return HttpResponseRedirect(reverse("account_email"))
if not email_address:
url = reverse("account_email")
else:
url = get_adapter(self.request).get_email_verification_redirect_url(
email_address
)
return HttpResponseRedirect(url)

def form_invalid(self, form):
attempts_left = flows.email_verification_by_code.record_invalid_attempt(
Expand Down

0 comments on commit 7fedd13

Please sign in to comment.