Commit da1d8575 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_core: do not send recovery email to unreachable addresses

parent 65f5f5e5
......@@ -434,6 +434,32 @@ class TestPasswordTool(ERP5TypeTestCase):
# But no mail has been sent
self.stepCheckNoMailSent()
def test_unreachable_email_on_person(self):
person = self.portal.person_module.newContent(
portal_type="Person",
reference="user",
default_email_text="user@example.invalid",
)
person.getDefaultEmailValue().declareUnreachable()
assignment = person.newContent(portal_type='Assignment')
assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference='user-login',
password='password',
)
login.validate()
self.tic()
self.logout()
ret = self.portal.portal_password.mailPasswordResetRequest(
user_login='user-login', REQUEST=self.portal.REQUEST)
# For security reasons, the message should always be the same
self.assertTrue("portal_status_message=An+email+has+been+sent+to+you." in str(ret))
# But no mail has been sent
self.stepCheckNoMailSent()
def test_acquired_email_on_person(self):
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
......
......@@ -164,6 +164,12 @@ class PasswordTool(BaseTool):
'ERP5.PasswordTool', INFO,
"User {user} does not have an email address".format(user=user_login)
)
elif email_value.getValidationState() != "reachable":
error_encountered = True
LOG(
'ERP5.PasswordTool', INFO,
"User {user} does not have a valid email address".format(user=user_login)
)
if error_encountered:
if batch:
raise RuntimeError(msg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment