mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-21 18:11:11 +00:00
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
This commit is contained in:
parent
ad9677a14f
commit
096ea031de
4 changed files with 45 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue