I could see it going one of two ways. Either she would show him the code to the door before she goes to bed, or he would leave during the night and prop it open to get back inside. Since she would be asleep, she wouldn’t know he was going out in the first place, so she would wake up (maybe he leaves the door propped open because he forgets to close it) and have a reason to show him the code then?