Esempio n. 1
0
def send_verify_email(user, domain=''):
    """
    Send verify email to user's valid email

    Args:
        user (object): The user instance
    """

    if has_user_activate_token():
        send_activate_token_email(user, domain)

    if has_user_verify_code():
        send_verify_code_email(user)
    def create(self, validated_data):
        """
        Override create method to create user password
        """
        user = super().create(validated_data)
        user.set_password(validated_data['password'])

        # Disable veriried if enable verify user, else set it enabled
        if has_user_activate_token() or has_user_verify_code():
            set_user_verified(user, False)
        else:
            set_user_verified(user, True)
        user.save()
        return user
    def create(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data)
        serializer.is_valid(raise_exception=True)

        user = serializer.save()
        data = get_user_profile_data(user)

        domain = get_current_domain(request)

        # Send email activation link
        if has_user_activate_token() or has_user_verify_code():
            send_verify_email(user, domain)
        else:
            send_email_welcome(user)

        return Response(data, status=status.HTTP_201_CREATED)
Esempio n. 4
0
 def test_has_user_activate_token_enabled(self):
     self.assertTrue(users.has_user_activate_token())
Esempio n. 5
0
 def test_no_has_user_activate_token_enabled(self):
     self.assertFalse(users.has_user_activate_token())