-
-
Notifications
You must be signed in to change notification settings - Fork 450
Fix newsletter subscription validation blocking legitimate resubscriptions #5139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…cribed email Co-authored-by: addison74 <[email protected]>
Co-authored-by: addison74 <[email protected]>
Co-authored-by: addison74 <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where guest checkout fails when using an email address that has an active newsletter subscription. The root cause was overly strict validation in the subscribe() method that prevented even the owner of an email from resubscribing.
Key Changes:
- Modified the
subscribe()method to allow logged-in users to resubscribe their own email without errors - Added early return to avoid unnecessary database operations and duplicate confirmation emails when a user resubscribes an already-subscribed email
- Improved code comments to clarify the resubscription logic
| // Allow resubscription if user is subscribing their own email | ||
| if (!$isSubscribeOwnEmail) { | ||
| Mage::throwException(Mage::helper('newsletter')->__('This email address is already registered.')); | ||
| } | ||
|
|
||
| // User is resubscribing their own email that's already subscribed | ||
| // Return early to avoid unnecessary save() and duplicate confirmation emails | ||
| return $this->getStatus(); |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new behavior that allows logged-in users to resubscribe their own email without throwing an exception is not covered by tests. The existing cypress test at cypress/e2e/openmage/frontend/homepage/newsletter.cy.js only tests guest subscription scenarios. Consider adding a test case that verifies a logged-in user can resubscribe their own email without errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add test to cypress/e2e/openmage/frontend/customer/account.cy.js



Fix guest checkout failure when email has active newsletter subscription
Problem Analysis
subscribe()methodSolution Implementation
subscribe()method to allow resubscription when user subscribes their own emailTesting & Validation
Code Review & Security
Summary
This minimal change (3 lines added + formatting) fixes the issue by making the newsletter subscription validation context-aware. It allows logged-in users to resubscribe their own email without errors, while still preventing spam/abuse from guests trying to subscribe other people's emails.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.