-- save password for prevent change password during fediauth process -- issue: https://forum.minetest.net/viewtopic.php?p=429275#p429275 function fediauth.save_passw(playername) local auth_data = minetest.get_auth_handler().get_auth(playername) if fediauth.storage:get_string(playername .. "_pwd") == "" then minetest.log("action", "[fediauth] save password of '" .. playername .. "'") minetest.set_player_password(playername, auth_data.password) fediauth.storage:set_string(playername .. "_pwd", auth_data.password) end end -- discard password function fediauth.discard_passw(playername) local auth_data = minetest.get_auth_handler().get_auth(playername) local stored_pwd = fediauth.storage:get_string(playername .. "_pwd") if stored_pwd ~= "" then if stored_pwd == auth_data.password then fediauth.storage:set_string(playername .. "_pwd", "") else local msg_violation = "[fediauth] '" .. playername .. "' attempt change password! Restoring" minetest.log("warning", msg_violation) if fediauth.matterbridge_avalaible then yl_matterbridge.send_to_bridge("", msg_violation) end minetest.kick_player(playername, "password protection violation") minetest.set_player_password(playername, stored_pwd) fediauth.storage:set_string(playername .. "_pwd", "") end end end