Electrochemical extraction of rare earth metals in molten fluorides