mirror of
https://github.com/MinetestForFun/mysql_auth.git
synced 2025-01-08 00:50:25 +01:00
Include player name in error reports; log auth.txt import start/end
This commit is contained in:
parent
b2670cae08
commit
79699b500c
@ -4,13 +4,14 @@ local modpath = minetest.get_modpath(modname)
|
|||||||
local thismod = _G[modname]
|
local thismod = _G[modname]
|
||||||
|
|
||||||
function thismod.import_auth_txt()
|
function thismod.import_auth_txt()
|
||||||
|
minetest.log('action', modname .. ": Importing auth.txt")
|
||||||
local auth_file_path = minetest.get_worldpath() .. '/auth.txt'
|
local auth_file_path = minetest.get_worldpath() .. '/auth.txt'
|
||||||
local create_auth_stmt = thismod.create_auth_stmt
|
local create_auth_stmt = thismod.create_auth_stmt
|
||||||
local create_auth_params = thismod.create_auth_params
|
local create_auth_params = thismod.create_auth_params
|
||||||
local conn = thismod.conn
|
local conn = thismod.conn
|
||||||
local file, errmsg = io.open(auth_file_path, 'rb')
|
local file, errmsg = io.open(auth_file_path, 'rb')
|
||||||
if not file then
|
if not file then
|
||||||
minetest.log("info", modname .. ": " .. auth_file_path .. " could not be opened for reading" ..
|
minetest.log('action', modname .. ": " .. auth_file_path .. " could not be opened for reading" ..
|
||||||
"(" .. errmsg .. "); no auth entries imported")
|
"(" .. errmsg .. "); no auth entries imported")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -42,4 +43,5 @@ function thismod.import_auth_txt()
|
|||||||
conn:query('COMMIT')
|
conn:query('COMMIT')
|
||||||
conn:query('SET autocommit=1')
|
conn:query('SET autocommit=1')
|
||||||
io.close(file)
|
io.close(file)
|
||||||
|
minetest.log('action', modname .. ": Finished importing auth.txt")
|
||||||
end
|
end
|
||||||
|
36
init.lua
36
init.lua
@ -266,7 +266,7 @@ do
|
|||||||
get_auth_params:set(1, name)
|
get_auth_params:set(1, name)
|
||||||
local success, msg = pcall(get_auth_stmt.exec, get_auth_stmt)
|
local success, msg = pcall(get_auth_stmt.exec, get_auth_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": get_auth failed: " .. msg)
|
minetest.log('error', modname .. ": get_auth(" .. name .. ") failed: " .. msg)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
get_auth_stmt:store_result()
|
get_auth_stmt:store_result()
|
||||||
@ -275,8 +275,8 @@ do
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
while get_auth_stmt:fetch() do
|
while get_auth_stmt:fetch() do
|
||||||
minetest.log('warning', modname .. ": get_auth: multiples lines were returned for '" ..
|
minetest.log('warning', modname .. ": get_auth(" .. name .. "): multiples lines were" ..
|
||||||
name .. "'")
|
" returned")
|
||||||
end
|
end
|
||||||
local password, privs_str, lastlogin = get_auth_results:get(1), get_auth_results:get(2),
|
local password, privs_str, lastlogin = get_auth_results:get(1), get_auth_results:get(2),
|
||||||
get_auth_results:get(3)
|
get_auth_results:get(3)
|
||||||
@ -313,12 +313,12 @@ do
|
|||||||
create_auth_params:set(4, math.floor(os.time()))
|
create_auth_params:set(4, math.floor(os.time()))
|
||||||
local success, msg = pcall(create_auth_stmt.exec, create_auth_stmt)
|
local success, msg = pcall(create_auth_stmt.exec, create_auth_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": create_auth failed: " .. msg)
|
minetest.log('error', modname .. ": create_auth(" .. name .. ") failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if create_auth_stmt:affected_rows() ~= 1 then
|
if create_auth_stmt:affected_rows() ~= 1 then
|
||||||
minetest.log('error', modname .. ": create_auth failed: affected row count is " ..
|
minetest.log('error', modname .. ": create_auth(" .. name .. ") failed: affected row" ..
|
||||||
create_auth_stmt:affected_rows() .. ", expected 1")
|
" count is " .. create_auth_stmt:affected_rows() .. ", expected 1")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -329,12 +329,12 @@ do
|
|||||||
delete_auth_params:set(1, name)
|
delete_auth_params:set(1, name)
|
||||||
local success, msg = pcall(delete_auth_stmt.exec, delete_auth_stmt)
|
local success, msg = pcall(delete_auth_stmt.exec, delete_auth_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": delete_auth failed: " .. msg)
|
minetest.log('error', modname .. ": delete_auth(" .. name .. ") failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if delete_auth_stmt:affected_rows() ~= 1 then
|
if delete_auth_stmt:affected_rows() ~= 1 then
|
||||||
minetest.log('error', modname .. ": delete_auth failed: affected row count is " ..
|
minetest.log('error', modname .. ": delete_auth(" .. name .. ") failed: affected row" ..
|
||||||
delete_auth_stmt:affected_rows() .. ", expected 1")
|
" count is " .. delete_auth_stmt:affected_rows() .. ", expected 1")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -350,12 +350,12 @@ do
|
|||||||
set_password_params:set(2, name)
|
set_password_params:set(2, name)
|
||||||
local success, msg = pcall(set_password_stmt.exec, set_password_stmt)
|
local success, msg = pcall(set_password_stmt.exec, set_password_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": set_password failed: " .. msg)
|
minetest.log('error', modname .. ": set_password(" .. name .. ") failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if set_password_stmt:affected_rows() ~= 1 then
|
if set_password_stmt:affected_rows() ~= 1 then
|
||||||
minetest.log('error', modname .. ": set_password failed: affected row count is " ..
|
minetest.log('error', modname .. ": set_password(" .. name .. ") failed: affected row" ..
|
||||||
set_password_stmt:affected_rows() .. ", expected 1")
|
" count is " .. set_password_stmt:affected_rows() .. ", expected 1")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -368,13 +368,13 @@ do
|
|||||||
set_privileges_params:set(2, name)
|
set_privileges_params:set(2, name)
|
||||||
local success, msg = pcall(set_privileges_stmt.exec, set_privileges_stmt)
|
local success, msg = pcall(set_privileges_stmt.exec, set_privileges_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": set_privileges failed: " .. msg)
|
minetest.log('error', modname .. ": set_privileges(" .. name .. ") failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
minetest.notify_authentication_modified(name)
|
minetest.notify_authentication_modified(name)
|
||||||
if set_privileges_stmt:affected_rows() ~= 1 then
|
if set_privileges_stmt:affected_rows() ~= 1 then
|
||||||
minetest.log('error', modname .. ": set_privileges failed: affected row count is " ..
|
minetest.log('error', modname .. ": set_privileges(" .. name .. ") failed: affected row" ..
|
||||||
set_privileges_stmt:affected_rows() .. ", expected 1")
|
" count is " .. set_privileges_stmt:affected_rows() .. ", expected 1")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -388,12 +388,12 @@ do
|
|||||||
record_login_params:set(2, name)
|
record_login_params:set(2, name)
|
||||||
local success, msg = pcall(record_login_stmt.exec, record_login_stmt)
|
local success, msg = pcall(record_login_stmt.exec, record_login_stmt)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ": record_login failed: " .. msg)
|
minetest.log('error', modname .. ": record_login(" .. name .. ") failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if record_login_stmt:affected_rows() ~= 1 then
|
if record_login_stmt:affected_rows() ~= 1 then
|
||||||
minetest.log('error', modname .. ": record_login failed: affected row count is " ..
|
minetest.log('error', modname .. ": record_login(" .. name .. ") failed: affected row" ..
|
||||||
record_login_stmt:affected_rows() .. ", expected 1")
|
" count is " .. record_login_stmt:affected_rows() .. ", expected 1")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user