Someone on the radio yesterday suggested having three people in the cockpit at all times.
That's not going to work in all situations, but what could work is drawing three people from a pool of available onboard staff (taken from pilots, air marshals when they exist, and flight attendants).
In a situation such as the tragedy that happened to Germanwings, any two of the three would be able to override the door lock, and hopefully regain control of the plane before things became dire.
Pilots and air marshals (when available) would always be part of the pool. Flight attendants would be picked randomly per flight, if necessary (due to current level of airline/government paranoia) being informed of their additional "duty" from the tower just before takeoff.