From 096ea031de5bdb3e51d2ceb12e6b7e2f2053081e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 26 Aug 2017 07:17:05 +0100 Subject: 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 --- builtin/game/auth.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'builtin/game/auth.lua') 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() -- cgit v1.2.3