Ejemplo n.º 1
0
    def send_confirmation_email(cls, user, new_email=None):
        """Process the email confirmation sending."""
        pending_info = {
            'user': user,
            'category': ActionCategory.CONFIRM_EMAIL,
            'token': get_uuid(cls.DEFAULT_TOKEN_LENGHT),
        }

        if new_email:
            serializer = EmailSerializer(data={'email': new_email})
            serializer.is_valid(raise_exception=True)
            pending_info['extra'] = serializer.validated_data

        pending_action, _ = PendingAction.objects.get_or_create(
            user=user,
            category=ActionCategory.CONFIRM_EMAIL,
            defaults=pending_info,
        )
        AuthEmailService.send_confirm_email(pending_action)
Ejemplo n.º 2
0
 def test_send_reset_password(test_user):
     AuthEmailService.send_reset_password(
         PendingActionFactory(user=test_user,
                              category=ActionCategory.RESET_PASSWORD))
     assert mail_outbox() == 1
Ejemplo n.º 3
0
 def test_send_confirm_email(test_user):
     AuthEmailService.send_confirm_email(
         PendingActionFactory(user=test_user,
                              category=ActionCategory.CONFIRM_EMAIL))
     assert mail_outbox() == 1