Open appgurueu opened 1 year ago
The player will now be verified to have the necessary privileges before taking any action.
About the callbacks every time the formspec is shown, I'm not sure how to fix it...
Well, you want a callback / closure-style handler approach. That is very reasonable; it's one of the two main features of fslib
. If you were to implement something similar yourself, you could just have a handler which deals with all yourmod:yourformname
events and dispatches based on the player name to a table of closures. You'd have to make sure to delete entries in this table when formspecs are closed or players leave to not leak memory.
I have reworked the mod, but I still haven't fixed the callback
Great :)
The "memory leak" is probably not very high priority.
on_player_receive_fields_handler
does not check that the submitting player (still) has the necessary privilege. Cheaters can submit any form at any time, so this is a problem. In practice mod security will check form names against form submissions, so it probably won't be a problem (except for recently demoted admins, which is very much an edge case). But to be on the safe side you should do priv validation at the time of form submission (in on receive fields).