Magnetically mediated superconductivity