There is a time delay between putting the code and actual door opening .
The QRH says ' is somebody is trying to open the door using the code , action - DENY entry .'
That's right. All that you need is a camera that shows you the cabin and the galley so that you know when something suspicious is going on and you need the curtain closed so that passengers don't know when the door is open. And the passengers need to wait behind the curtain for the loo.
All this will keep you relatively and acceptably safe I would say.