The way you have described it, no, it was not illegal. It may or may not have been inappropriate but there are very few privacy laws in the workplace and this does not violate what few there are.