summaryrefslogtreecommitdiff
path: root/src/mailman/app/subscriptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/app/subscriptions.py')
-rw-r--r--src/mailman/app/subscriptions.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py
index 63aebbecb..9e915a25d 100644
--- a/src/mailman/app/subscriptions.py
+++ b/src/mailman/app/subscriptions.py
@@ -306,10 +306,8 @@ class SubscriptionWorkflow(_SubscriptionWorkflowCommon):
def _step_do_subscription(self):
# We can immediately subscribe the user to the mailing list.
self.member = self.mlist.subscribe(self.subscriber)
- # This workflow is done so throw away any associated state.
- if self.token is not None:
- getUtility(IWorkflowStateManager).discard(self.token)
- self._set_token(TokenOwner.no_one)
+ assert self.token is None and self.token_owner is TokenOwner.no_one, (
+ 'Unexpected active token at end of subscription workflow')
def _step_send_confirmation(self):
self._set_token(TokenOwner.subscriber)
@@ -451,6 +449,12 @@ class UnSubscriptionWorkflow(_SubscriptionWorkflowCommon):
self.subscriber = self.user
# Reset the token so it can't be used in a replay attack.
self._set_token(TokenOwner.no_one)
+ # Restore the member object.
+ self.member = self.mlist.regular_members.get_member(self.address.email)
+ # It's possible the member was already unsubscribed while we were
+ # waiting for the confirmation.
+ if self.member is None:
+ return
# The user has confirmed their unsubscription request
next_step = ('moderation_checks'
if self.mlist.unsubscription_policy in (
@@ -467,10 +471,8 @@ class UnSubscriptionWorkflow(_SubscriptionWorkflowCommon):
# The member has already been unsubscribed.
pass
self.member = None
- # This workflow is done so throw away any associated state.
- if self.token is not None:
- getUtility(IWorkflowStateManager).discard(self.token)
- self._set_token(TokenOwner.no_one)
+ assert self.token is None and self.token_owner is TokenOwner.no_one, (
+ 'Unexpected active token at end of subscription workflow')
def _step_unsubscribe_from_restored(self):
# Prevent replay attacks.