you're right, this approach has lots of issues. but probably with lots of trial and error one can code a somewhat usable program.
for example, when someone enters a password, that could be valid just until the first button press, than the variable storing the password will reset.
also, it is important that the entered password to not appear in the terminal. so the users could not see each others passwords.