From aec39e0166b80e88eebb9b0f0a9e13ae89bf3d99 Mon Sep 17 00:00:00 2001 From: mdtro <20070360+mdtro@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:11:22 -0500 Subject: [PATCH] provide helpful error message when option is disabled --- src/sentry/users/web/accounts.py | 7 +++++-- .../users/api/endpoints/test_user_emails_confirm.py | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sentry/users/web/accounts.py b/src/sentry/users/web/accounts.py index 550550fb6201c0..3446a58f5b5ce4 100644 --- a/src/sentry/users/web/accounts.py +++ b/src/sentry/users/web/accounts.py @@ -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 @@ -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 diff --git a/tests/sentry/users/api/endpoints/test_user_emails_confirm.py b/tests/sentry/users/api/endpoints/test_user_emails_confirm.py index e055b0b5004873..2758743f051be1 100644 --- a/tests/sentry/users/api/endpoints/test_user_emails_confirm.py +++ b/tests/sentry/users/api/endpoints/test_user_emails_confirm.py @@ -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." + )