LUA mod to enable Lobby/password based on JWT

I am trying to see if anyone has a lua script for checking a JWT for lobby or password and setting the room to enable those on creation? We are currently using the iframe API to enable the lobby but sometimes see users getting into the room before the lobby creation if they were in the waiting room. LUA is not my strong suit so was hoping someone had already done the leg work and was willing to share.

Just bumping this thread, any assistance would be greatly appreciated.

You can do all the logic in lobby impl for starter, and later you can extract it in your own module that run before the lobby on ‘muc-occupant-pre-join’, you can see the lobby one is with priority -4, so anything higher than that.

All changes will be here

Before that check whether you want to enable lobby, if you want to enable it:
do room:set_members_only(true); and when it is enabled if you want to pass through a participant do it the way whitelist works there.

Thank you @damencho! I will give that a shot.