A couple of ideas:
What is the battery state of charge? Can you monitor the battery voltage when the failure occurs? This could be just a battery issue.
Most battery maintenance systems have a low-voltage cutoff to protect the battery from deep discharge. I have encountered this when the battery is low near the end of a long ride (or if I forgot to charge it!). It will power the bike, but under heavier load - hills, etc. - the voltage drops, the cutoff shuts down the pack and the bike goes dead. After power-cycling the battery the BMS resets because the voltage has recovered back to above cut-off and the bike will operate again until another heavy load. This is similar to what you describe as happening after each on-off cycle
This could also be a thermal protection system in the controller or motor, but I doubt that it would heat up sufficiently in only a couple minutes, and then quickly cool to immediately reset after a power cycle.
Since the system resets after a power cycle it unlikely to be an intermittent connection or wiring failure.
Controllers will vary depending on the displays and motor types, so more info is needed to help find a replacement controller. Do a google search for ebike controllers and /or wiring - it will produce various schematics that might match the system.
I have found eBikeling.com to be a good source for "generic" ebike components, and their service is good.