diff options
author | rubenwardy <rubenwardy@gmail.com> | 2017-08-26 07:17:05 +0100 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-26 08:17:05 +0200 |
commit | 096ea031de5bdb3e51d2ceb12e6b7e2f2053081e (patch) | |
tree | 299fa6f103e70c091cbd73c221046ec2fc302d35 /builtin/game/auth.lua | |
parent | ad9677a14fb8ad1b4048e83a779e5ad36a99f2d0 (diff) | |
download | minetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.tar.gz minetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.tar.bz2 minetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.zip |
Add on_grant and on_revoke callbacks (#4713)
* Add register_on_priv_grant/revoke, and on_grant/revoke to privs. Call from /grant and /revoke
* Call on_grant and on_revoke callbacks from set_privs
Diffstat (limited to 'builtin/game/auth.lua')
-rw-r--r-- | builtin/game/auth.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua index 7a6be8788..4d5178ba7 100644 --- a/builtin/game/auth.lua +++ b/builtin/game/auth.lua @@ -125,6 +125,21 @@ core.builtin_auth_handler = { core.get_password_hash(name, core.settings:get("default_password"))) end + + -- Run grant callbacks + for priv, _ in pairs(privileges) do + if not core.auth_table[name].privileges[priv] then + core.run_priv_callbacks(name, priv, nil, "grant") + end + end + + -- Run revoke callbacks + for priv, _ in pairs(core.auth_table[name].privileges) do + if not privileges[priv] then + core.run_priv_callbacks(name, priv, nil, "revoke") + end + end + core.auth_table[name].privileges = privileges core.notify_authentication_modified(name) save_auth_file() |