Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Weblate 2026.12
* Prevented component creation from writing translation templates outside its repository.
* Applied :setting:`VCS_RESTRICT_PRIVATE` and trusted-host exemptions to :ref:`GitHub App manifest-code and OAuth exchanges <code-hosting-github-app-register>` and API requests, including redirects and pagination URLs.
* Revoked stale OAuth e-mail recovery addresses and reconciled the :ref:`account e-mail <user-profile>` when its last verification is removed.
* Required e-mail confirmation when adding an address or resetting a password for an account without a primary e-mail.
* Preserved internationalized recipient domains when sending :ref:`account e-mails <user-profile>` and other notifications.
* Filtered the site-wide changes listings and feeds by workspace visibility, so workspaces the viewer cannot access no longer appear there.
* Restricted :ref:`webhook matching <hooks-target-matching>` to repository owners, preventing generic deliveries from triggering GitHub App updates through linked components.
Expand Down
5 changes: 3 additions & 2 deletions weblate/accounts/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ def require_email(
if user and weblate_action == "reset":
invalidate_reset_codes(user=user)

if user and user.email:
if user:
# Force validation of new e-mail address
if backend.name == "email":
return {"is_new": True}

return None
if user.email:
return None

if is_new and not details.get("email"):
raise AuthResponseError(
Expand Down
30 changes: 30 additions & 0 deletions weblate/accounts/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
ensure_valid(
strategy,
MagicMock(),
user=None,

Check failure on line 272 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "user" to "ensure_valid" has incompatible type "None"; expected "User"
registering_user=None,
weblate_action="activation",
new_association=False,
Expand Down Expand Up @@ -304,7 +304,7 @@
def test_password_reset_request_data_uses_session_email(self) -> None:
"""Password reset social auth can continue without e-mail in request data."""
request = RequestFactory().post("/complete/email/")
request.session = {

Check failure on line 307 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible types in assignment (expression has type "dict[str, object]", variable has type "SessionBase")
"password_reset": True,
PASSWORD_RESET_EMAIL_SESSION: "test@example.com",
}
Expand Down Expand Up @@ -558,6 +558,22 @@


class EmailRecoveryTest(BaseRegistrationTest):
@override_settings(REGISTRATION_CAPTCHA=False)
def test_empty_primary_email_requires_recovery_link(self) -> None:
user = User.objects.create_user("empty-primary", "")
social = user.social_auth.create(
provider="email", uid="recovery@example.org", id_key="email"
)
VerifiedEmail.objects.create(social=social, email="recovery@example.org")

with self.captureOnCommitCallbacks(execute=True):
response = self.client.post(
reverse("password_reset"), {"email": "recovery@example.org"}
)

self.assertRedirects(response, reverse("email-sent"))
self.assert_registration_mailbox("[Weblate] Password reset on Weblate")
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved

@override_settings(REGISTRATION_CAPTCHA=False)
def test_expired_email_setup_completes_password_recovery(self) -> None:
user = User.objects.create_user("email-only", "email-only@example.com")
Expand Down Expand Up @@ -864,7 +880,7 @@
self.assertEqual(
message.subject, "[Weblate] Verify your e-mail address on Weblate"
)
for content in (message.body, message.alternatives[0].content):

Check failure on line 883 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "tuple[bytes | EmailMessage | Message[str, str] | str, ...]" of "Any | tuple[bytes | EmailMessage | Message[str, str] | SafeMIMEText | str, str]" has no attribute "content"

Check failure on line 883 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "EmailMessage" of "EmailMessage | EmailMultiAlternatives" has no attribute "alternatives"
self.assertIn("Verify e-mail address", content)
self.assertIn("verification_code=", content)
self.assertNotIn("Confirm registration", content)
Expand All @@ -876,6 +892,20 @@
VerifiedEmail.objects.filter(email="unused@example.net").exists()
)

def test_empty_primary_email_requires_addition_link(self) -> None:
self.user.email = ""
self.user.save(update_fields=["email"])

response = self.submit_email("unused@example.net")

self.assertRedirects(response, reverse("email-sent"))
self.assert_registration_mailbox(
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
"[Weblate] Verify your e-mail address on Weblate"
)
self.assertFalse(
VerifiedEmail.objects.filter(email="unused@example.net").exists()
)

def test_add_email_confirmation(self) -> None:
self.check_add_email_confirmation(has_password=True)

Expand Down Expand Up @@ -998,7 +1028,7 @@
)
for content in (
guidance.body,
guidance.alternatives[0].content,

Check failure on line 1031 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "tuple[bytes | EmailMessage | Message[str, str] | str, ...]" of "Any | tuple[bytes | EmailMessage | Message[str, str] | SafeMIMEText | str, str]" has no attribute "content"

Check failure on line 1031 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "EmailMessage" of "EmailMessage | EmailMultiAlternatives" has no attribute "alternatives"
str(guidance.extra_headers),
):
self.assertNotIn(self.user.username, content)
Expand All @@ -1012,7 +1042,7 @@
)
self.assertIn(
f'href="http://example.com{reverse("password_reset")}"',
guidance.alternatives[0].content,

Check failure on line 1045 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "tuple[bytes | EmailMessage | Message[str, str] | str, ...]" of "Any | tuple[bytes | EmailMessage | Message[str, str] | SafeMIMEText | str, str]" has no attribute "content"

Check failure on line 1045 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "EmailMessage" of "EmailMessage | EmailMultiAlternatives" has no attribute "alternatives"
)
if len(mail.outbox) == 2:
self.assertEqual(
Expand Down Expand Up @@ -1040,7 +1070,7 @@
self.submit_email(self.owner.email)
self.assertIn(
'href="https://identity.example.org/recover"',
mail.outbox[0].alternatives[0].content,

Check failure on line 1073 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "tuple[bytes | EmailMessage | Message[str, str] | str, ...]" of "Any | tuple[bytes | EmailMessage | Message[str, str] | SafeMIMEText | str, str]" has no attribute "content"

Check failure on line 1073 in weblate/accounts/tests/test_registration.py

View workflow job for this annotation

GitHub Actions / mypy

Item "EmailMessage" of "EmailMessage | EmailMultiAlternatives" has no attribute "alternatives"
)

@override_settings(CONTACT_FORM="disabled")
Expand Down
Loading