summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/commands/docs/membership.txt32
-rw-r--r--src/mailman/commands/eml_membership.py14
2 files changed, 39 insertions, 7 deletions
diff --git a/src/mailman/commands/docs/membership.txt b/src/mailman/commands/docs/membership.txt
index 671d5109f..a04622cf7 100644
--- a/src/mailman/commands/docs/membership.txt
+++ b/src/mailman/commands/docs/membership.txt
@@ -204,12 +204,11 @@ Anne is no longer a member of the mailing list.
None
Anne does not need to leave a mailing list with the same email address she's
-subscribe with. Any of her registered and linked email addresses will do.
+subscribe with. Any of her registered, linked, and validated email addresses
+will do.
- >>> from datetime import datetime
>>> anne = getUtility(IUserManager).get_user('anne@example.com')
>>> address = anne.register('anne.person@example.org')
- >>> address.verified_on = datetime.now()
>>> results = Results()
>>> print mlist.members.get_member('anne@example.com')
@@ -221,13 +220,38 @@ subscribe with. Any of her registered and linked email addresses will do.
... From: anne.person@example.org
...
... """)
+
+Since Anne's alternative address has not yet been verified, it can't be used
+to unsubscribe Anne from the alpha mailing list.
+
+ >>> print command.process(mlist, msg, {}, (), results)
+ ContinueProcessing.no
+
+ >>> print unicode(results)
+ The results of your email command are provided below.
+ <BLANKLINE>
+ Invalid or unverified address: anne.person@example.org
+ <BLANKLINE>
+
+ >>> print mlist.members.get_member('anne@example.com')
+ <Member: Anne Person <anne@example.com>
+ on alpha@example.com as MemberRole.member>
+
+Once Anne has verified her alternative address though, it can be used to
+unsubscribe her from the list.
+
+ >>> from datetime import datetime
+ >>> address.verified_on = datetime.now()
+
+ >>> results = Results()
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.yes
-
+
>>> print unicode(results)
The results of your email command are provided below.
<BLANKLINE>
Anne Person <anne.person@example.org> left alpha@example.com
<BLANKLINE>
+
>>> print mlist.members.get_member('anne@example.com')
None
diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py
index 5b43276a8..55e866559 100644
--- a/src/mailman/commands/eml_membership.py
+++ b/src/mailman/commands/eml_membership.py
@@ -153,11 +153,21 @@ class Leave:
print >> results, _(
'$self.name: No valid address found to unsubscribe')
return ContinueProcessing.no
- user = getUtility(IUserManager).get_user(address)
+ user_manager = getUtility(IUserManager)
+ user = user_manager.get_user(address)
if user is None:
print >> results, _('No registered user for address: $address')
return ContinueProcessing.no
+ # The address that the -leave command was sent from, must be verified.
+ # Otherwise you could link a bogus address to anyone's account, and
+ # then send a leave command from that address.
+ if user_manager.get_address(address).verified_on is None:
+ print >> results, _('Invalid or unverified address: $address')
+ return ContinueProcessing.no
for user_address in user.addresses:
+ # Only recognize verified addresses.
+ if user_address.verified_on is None:
+ continue
member = mlist.members.get_member(user_address.address)
if member is not None:
break
@@ -167,8 +177,6 @@ class Leave:
'$self.name: $address is not a member of $mlist.fqdn_listname')
return ContinueProcessing.no
member.unsubscribe()
- # Get the user's full name.
- user = getUtility(IUserManager).get_user(address)
person = formataddr((user.real_name, address))
print >> results, _('$person left $mlist.fqdn_listname')
return ContinueProcessing.yes