diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua index 19af8db73..6b2c11630 100644 --- a/builtin/game/auth.lua +++ b/builtin/game/auth.lua @@ -39,6 +39,7 @@ local function read_auth_file() core.log("info", core.auth_file_path.." could not be opened for reading ("..errmsg.."); assuming new world") return end + minetest.log( "action", "Reading authentication data from disk..." ) for line in file:lines() do if line ~= "" then local fields = line:split(":", true) @@ -127,7 +128,7 @@ core.builtin_auth_handler = { privileges = core.string_to_privs(core.settings:get("default_privs")), last_login = os.time(), } - save_auth_file() +-- save_auth_file() -- save only when users logout or set a password end, set_password = function(name, password) assert(type(name) == "string") @@ -154,9 +155,15 @@ core.builtin_auth_handler = { save_auth_file() end, reload = function() + minetest.log( "action", "Reading authentication data from disk..." ) read_auth_file() return true end, + commit = function() + minetest.log( "action", "Writing authentication data manually (commit) to disk..." ) + save_auth_file() + return true + end, record_login = function(name) assert(type(name) == "string") assert(core.auth_table[name]).last_login = os.time() @@ -190,6 +197,7 @@ end core.set_player_password = auth_pass("set_password") core.set_player_privs = auth_pass("set_privileges") core.auth_reload = auth_pass("reload") +core.auth_commit = auth_pass("commit") local record_login = auth_pass("record_login") diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 3bd8f2f9c..e119d59be 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -279,6 +279,16 @@ core.register_chatcommand("auth_reload", { end, }) +core.register_chatcommand("auth_commit", { + params = "", + description = "write authentication data to disk", + privs = {server=true}, + func = function(name, param) + local done = core.auth_commit() + return done, (done and "Authentication data successfully saved to disk." or "Failed to write the auth.txt file.") + end, +}) + core.register_chatcommand("remove_player", { params = "", description = "Remove player data",