There is an emergency code for access to the flight deck in case of both pilot incapacitation.
The cabin crew have portable oxygen bottles so if they have passed out they could gain access to the flight deck, fit the oxy masks and recover the pilots.
They have to remember the code of course, and be somewhat pro active.