diff options
| author | Barry Warsaw | 2016-10-21 00:02:17 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-10-21 00:02:17 -0400 |
| commit | c8f3294e6b54552edd79bafa54207fdcfd61e2c0 (patch) | |
| tree | 3b26644ba1029b92955cc7b7246ff4835548d61e /src/mailman/app/subscriptions.py | |
| parent | 946aa8212e2187fd5d2f057f724cf65898f0b44a (diff) | |
| download | mailman-c8f3294e6b54552edd79bafa54207fdcfd61e2c0.tar.gz mailman-c8f3294e6b54552edd79bafa54207fdcfd61e2c0.tar.zst mailman-c8f3294e6b54552edd79bafa54207fdcfd61e2c0.zip | |
Diffstat (limited to 'src/mailman/app/subscriptions.py')
| -rw-r--r-- | src/mailman/app/subscriptions.py | 18 |
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. |
