i think your issue is
- code needs to recognize that the correct password is entered and the door is ok to be opened
- recognize that is has been opened after the correct password entered
- recognize that it is subsequently closed and the password is cleared requiring it to be reentered
i think it's odd that you call each of your sub-functions, each of which monitors a separate input.
i would have a sub-function that monitors all the inputs and performs some action based on the button press
the left button would increment the current digit, the right button would advance to the next digit, the door sensor might turn on the alarm if the door is opened and the password not set correctly
if this is mimicking a combination lock, does the password need to be jumbled to reset it. could that automatically happen after the door is closed.