Skip to content

Commit

Permalink
provide helpful error message when option is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtro committed Dec 13, 2024
1 parent 85ac0f2 commit aec39e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/sentry/users/web/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.auth import login as login_user
from django.core.signing import BadSignature, SignatureExpired
from django.db import router, transaction
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound, HttpResponseRedirect
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.urls import reverse
from django.utils.translation import gettext as _
from django.views.decorators.http import require_http_methods
Expand Down Expand Up @@ -402,7 +402,10 @@ def confirm_signed_email(

use_signed_urls = options.get("user-settings.signed-url-confirmation-emails")
if not use_signed_urls:
return HttpResponseNotFound()
msg = ERR_CONFIRMING_EMAIL
level = messages.ERROR
messages.add_message(request, level, msg)
return HttpResponseRedirect(reverse("sentry-account-settings-emails"))

msg = _("Thanks for confirming your email")
level = messages.SUCCESS
Expand Down
9 changes: 8 additions & 1 deletion tests/sentry/users/api/endpoints/test_user_emails_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,11 @@ def test_confirm_email_signed_urls_disabled(self):
resp = self.client.get(
reverse("sentry-account-confirm-signed-email", args=[signed_data]), follow=True
)
assert resp.status_code == 404
assert resp.status_code == 200

messages = list(resp.context["messages"])
assert len(messages) == 1
assert (
messages[0].message
== "There was an error confirming your email. Please try again or visit your Account Settings to resend the verification email."
)

0 comments on commit aec39e0

Please sign in to comment.