This would be fairly easy to implement. The basic logic would be:
During room join, a password can be provided. If the room exists, the password is checked against it. If it doesn't exist, the room is created and locked with the given password.
In an unlocked room, any user can choose to lock it.
Only the initiating user becomes the creator.
All users can see the room is locked and can click on a toggle button to reveal the current password.
In a locked room, only the creating user can unlock it. If the creator leaves and there are no other users marked as moderators, the room becomes unmoderated + locked, in which case all users can unlock.
So, in effect there are a few room states:
Unlocked
Locked, moderated
Has a user with the moderator property set, either given from a previous moderator, or acquired from room creation.
Locked, unmoderated
Has no user with the moderator. Any user can return the room to unlocked.
This would be fairly easy to implement. The basic logic would be:
So, in effect there are a few room states: