edited middleware to also proces documents so user obj is connected