[BUG] two tokens get created
mathijsfr opened this issue · comments
mathijsfr commented
Whenever I post an api call with an email to http://127.0.0.1:8000/api/password_reset/, the following code is run twice:
@receiver(reset_password_token_created)
def password_reset_token_created(sender, instance, reset_password_token, *args, **kwargs):
email_plaintext_message = "{}?token={}".format(reverse('password_reset:reset-password-request'), reset_password_token.key)
print(reset_password_token.key)
send_mail(
# title:
"Password Reset for {title}".format(title="Some website title"),
# message:
email_plaintext_message,
# from:
'[example@example.com]',
# to:
[reset_password_token.user.email],
fail_silently=False
)
This sends two e-mails to my mail with two different tokens. Each time, only one of the tokens work. For example:
9ae5ad217f6edf91185d609
and
35ac9fd6e439b3
in two separate emails.
What do I do to only send 1 e-mail each time with the correct token?
mathijsfr commented
Found the problem. Two seperate accounts can't have the same e-mail. An e-mail is send for each user having the requested e-mail, which I realize is to be expected.