eureka!
Insert a microchip in the palm? of pilots, you can then swap it at the door to open them...or a palm reader, iris scan etc. No need for codes anymore, no one being locked out anymore...
and when the pilot is alone on the flight deck, every 15 seconds he needs to press a button to show the cabin crew he is still alive ... or awake... then again, this should even be mandatory these days with both of them on the flight deck