mirror of
https://github.com/MinetestForFun/mysql_auth.git
synced 2025-01-08 00:50:25 +01:00
Better error reporting upon unexpected affected_rows
This commit is contained in:
parent
52d07a9382
commit
84fff7e863
36
init.lua
36
init.lua
@ -277,13 +277,18 @@ do
|
|||||||
minetest.log('error', modname .. ': create_auth failed: ' .. msg)
|
minetest.log('error', modname .. ': create_auth failed: ' .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return (create_auth_stmt:affected_rows() == 1)
|
if create_auth_stmt:affected_rows() ~= 1 then
|
||||||
|
minetest.log('error', modname .. ": create_auth failed: affected row count is " ..
|
||||||
|
create_auth_stmt:affected_rows() .. ", expected 1")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
set_password = function(name, password)
|
set_password = function(name, password)
|
||||||
assert(type(name) == 'string')
|
assert(type(name) == 'string')
|
||||||
assert(type(password) == 'string')
|
assert(type(password) == 'string')
|
||||||
if not thismod.auth_handler.get_auth(name) then
|
if not thismod.auth_handler.get_auth(name) then
|
||||||
thismod.auth_handler.create_auth(name, password, ' because set_password was requested')
|
return thismod.auth_handler.create_auth(name, password, ' because set_password was requested')
|
||||||
else
|
else
|
||||||
minetest.log('info', modname .. " setting password of player '"..name.."'")
|
minetest.log('info', modname .. " setting password of player '"..name.."'")
|
||||||
set_password_params:set(1, password)
|
set_password_params:set(1, password)
|
||||||
@ -293,8 +298,13 @@ do
|
|||||||
minetest.log('error', modname .. ': set_password failed: ' .. msg)
|
minetest.log('error', modname .. ': set_password failed: ' .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
if set_password_stmt:affected_rows() ~= 1 then
|
||||||
|
minetest.log('error', modname .. ": set_password failed: affected row count is " ..
|
||||||
|
set_password_stmt:affected_rows() .. ", expected 1")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
return (set_password_stmt:affected_rows() == 1)
|
|
||||||
end,
|
end,
|
||||||
set_privileges = function(name, privileges)
|
set_privileges = function(name, privileges)
|
||||||
assert(type(name) == 'string')
|
assert(type(name) == 'string')
|
||||||
@ -303,11 +313,16 @@ do
|
|||||||
set_privileges_params:set(2, name)
|
set_privileges_params:set(2, name)
|
||||||
local success, msg = pcall(function () set_privileges_stmt:exec() end)
|
local success, msg = pcall(function () set_privileges_stmt:exec() end)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ': set_privileges failed: ' .. msg)
|
minetest.log('error', modname .. ": set_privileges failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
--minetest.notify_authentication_modified(name)
|
minetest.notify_authentication_modified(name)
|
||||||
return (set_privileges_stmt:affected_rows() == 1)
|
if set_privileges_stmt:affected_rows() ~= 1 then
|
||||||
|
minetest.log('error', modname .. ": set_privileges failed: affected row count is " ..
|
||||||
|
set_privileges_stmt:affected_rows() .. ", expected 1")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
reload = function()
|
reload = function()
|
||||||
return true
|
return true
|
||||||
@ -318,10 +333,15 @@ do
|
|||||||
record_login_params:set(2, name)
|
record_login_params:set(2, name)
|
||||||
local success, msg = pcall(function () record_login_stmt:exec() end)
|
local success, msg = pcall(function () record_login_stmt:exec() end)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log('error', modname .. ': record_login failed: ' .. msg)
|
minetest.log('error', modname .. ": record_login failed: " .. msg)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return (record_login_stmt:affected_rows() == 1)
|
if record_login_stmt:affected_rows() ~= 1 then
|
||||||
|
minetest.log('error', modname .. ": record_login failed: affected row count is " ..
|
||||||
|
record_login_stmt:affected_rows() .. ", expected 1")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user