mirror of
https://git.phreedom.club/localhost_frssoft/fediauth
synced 2025-07-21 06:34:57 -04:00
fork creation done
This commit is contained in:
parent
376d163d08
commit
3466db227f
24 changed files with 416 additions and 1652 deletions
|
@ -2,18 +2,18 @@
|
|||
-- privs to revoke until the verification code is validated
|
||||
local temp_revoke_privs = {}
|
||||
|
||||
-- mark player health-related privs as "otp_keep" (they don't get removed while entering the otp code)
|
||||
-- mark player health-related privs as "fediauth_keep" (they don't get removed while entering the fediauth code)
|
||||
for _, name in ipairs({"fly", "noclip"}) do
|
||||
local priv_def = minetest.registered_privileges[name]
|
||||
if priv_def then
|
||||
priv_def.otp_keep = true
|
||||
priv_def.fediauth_keep = true
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
-- collect all privs to revoke while entering the otp code
|
||||
-- collect all privs to revoke while entering the fediauth code
|
||||
for name, priv_def in pairs(minetest.registered_privileges) do
|
||||
if not priv_def.otp_keep then
|
||||
if not priv_def.fediauth_keep then
|
||||
-- not marked explicitly as "keep"
|
||||
table.insert(temp_revoke_privs, name)
|
||||
end
|
||||
|
@ -21,9 +21,9 @@ minetest.register_on_mods_loaded(function()
|
|||
end)
|
||||
|
||||
-- moves all "temp_revoke_privs" to mod-storage
|
||||
function otp.revoke_privs(playername)
|
||||
function fediauth.revoke_privs(playername)
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
if otp.storage:get_string(playername .. "_privs") == "" then
|
||||
if fediauth.storage:get_string(playername .. "_privs") == "" then
|
||||
local moved_privs = {}
|
||||
|
||||
for _, priv_name in ipairs(temp_revoke_privs) do
|
||||
|
@ -33,15 +33,15 @@ function otp.revoke_privs(playername)
|
|||
end
|
||||
end
|
||||
|
||||
minetest.log("action", "[otp] revoking privs of '" .. playername .. "' list: " .. dump(moved_privs))
|
||||
minetest.log("action", "[fediauth] revoking privs of '" .. playername .. "' list: " .. dump(moved_privs))
|
||||
minetest.set_player_privs(playername, privs)
|
||||
otp.storage:set_string(playername .. "_privs", minetest.serialize(moved_privs))
|
||||
fediauth.storage:set_string(playername .. "_privs", minetest.serialize(moved_privs))
|
||||
end
|
||||
end
|
||||
|
||||
-- moves all privs from mod-storage into the live privs
|
||||
function otp.regrant_privs(playername)
|
||||
local stored_priv_str = otp.storage:get_string(playername .. "_privs")
|
||||
function fediauth.regrant_privs(playername)
|
||||
local stored_priv_str = fediauth.storage:get_string(playername .. "_privs")
|
||||
if stored_priv_str ~= "" then
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
local stored_privs = minetest.deserialize(stored_priv_str)
|
||||
|
@ -51,8 +51,8 @@ function otp.regrant_privs(playername)
|
|||
privs[priv_name] = true
|
||||
end
|
||||
|
||||
minetest.log("action", "[otp] regranting privs of '" .. playername .. "' list: " .. dump(stored_privs))
|
||||
minetest.log("action", "[fediauth] regranting privs of '" .. playername .. "' list: " .. dump(stored_privs))
|
||||
minetest.set_player_privs(playername, privs)
|
||||
otp.storage:set_string(playername .. "_privs", "")
|
||||
fediauth.storage:set_string(playername .. "_privs", "")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue