Critical current of a magnetic–superconducting heterostructure: diode effect