Coverage for users/signals.py: 21%
10 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-05-03 16:52 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-05-03 16:52 -0600
1# from django.dispatch import receiver
2# from django.db.models import signals
3# from .models import User
4from .serializers import ResetPasswordSerializer
5from .services import send_initial_register_password_email
8# @receiver(signals.post_save, sender=User)
9def send_email_to_passwordless_user(sender, instance, created, *args, **kwargs):
10 if created:
11 if instance.has_usable_password():
12 data = {"email": instance.email, "panel": "M"}
13 serializer = ResetPasswordSerializer(data=data)
14 serializer.is_valid(True)
15 url, user = serializer.save(data)
16 send_initial_register_password_email(user, url)