Skip to content

Commit

Permalink
Provide the old email address in the confirmation_complete signal.
Browse files Browse the repository at this point in the history
This is useful to confirmation_complete signal handlers that need to
update a mailing list subscription with the new address.
  • Loading branch information
Tom Vaughan committed Apr 12, 2012
1 parent 33116b9 commit 7ee401e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions docs/signals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ the ``user`` argument which Django's :class:`User` class.
confirmation_complete
---------------------

A user has succesfully changed their email. The signal provides you with
the ``user`` argument which Django's :class:`User` class.
A user has succesfully changed their email. The signal provides you
with the ``user`` argument which Django's :class:`User` class, and the
``old_email`` argument which is the user's old email address as a
string.

password_complete
-----------------
Expand Down
11 changes: 7 additions & 4 deletions userena/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ def confirm_email(self, username, confirmation_key):
"""
Confirm an email address by checking a ``confirmation_key``.
A valid ``confirmation_key`` will set the newly wanted e-mail address
as the current e-mail address. Returns the user after success or
``False`` when the confirmation key is invalid.
A valid ``confirmation_key`` will set the newly wanted e-mail
address as the current e-mail address. Returns the user after
success or ``False`` when the confirmation key is
invalid. Also sends the ``confirmation_complete`` signal.
:param username:
String containing the username of the user that wants their email
Expand All @@ -164,14 +165,16 @@ def confirm_email(self, username, confirmation_key):
return False
else:
user = userena.user
old_email = user.email
user.email = userena.email_unconfirmed
userena.email_unconfirmed, userena.email_confirmation_key = '',''
userena.save(using=self._db)
user.save(using=self._db)

# Send the confirmation_complete signal
userena_signals.confirmation_complete.send(sender=None,
user=user)
user=user,
old_email=old_email)

return user
return False
Expand Down
2 changes: 1 addition & 1 deletion userena/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

signup_complete = Signal(providing_args=["user",])
activation_complete = Signal(providing_args=["user",])
confirmation_complete = Signal(providing_args=["user",])
confirmation_complete = Signal(providing_args=["user","old_email"])
password_complete = Signal(providing_args=["user",])

0 comments on commit 7ee401e

Please sign in to comment.