Is it legal to pass a car on the right when that car is turning?
Is it legal? That depends on the country's traffic laws and on the exact layout of the intersection. The traffic laws that I am familiar with (Denmark, Austria) indicate that the bicyclist you describe was wrong to overtake a right-turning car on the car's right side.

If there is a bike lane that extends through the intersection, then AFAIK the cyclist always has right of way. The car must wait until it can turn without blocking any bikes.

If there is a bike lane that stops before the intersection, or 
if there is no bike lane then the cyclist must place himself in the proper traffic lane. If he wants to go straight, he may not be in the right-turn lane. 

As a driver, what I usually do coming to a stop at an intersection is to place my car so close to the curb that no bikes can pass on that side. Safety benefits:
If they want to go straight, they can safely overtake me on my left side.
If they want to turn right too, they must line up behind me and turn after I have turned.

As a cyclist, I always operate under the assumption that I am invisible, because too many drivers neglect to look for bicycle traffic. (They often neglect to check for any traffic, but that's irrelevant on this site.)

The above presumes right-hand driving.