Boundary and scattering rigidity problems in the presence of a magnetic field and a potential