mirror of
https://github.com/MinetestForFun/mysql_auth.git
synced 2025-01-08 17:10:24 +01:00
Add auth enumeration func, fix cdata being returned as last_login
This commit is contained in:
parent
333fc8916e
commit
5cebbaf03c
21
init.lua
21
init.lua
@ -235,6 +235,9 @@ do
|
|||||||
local record_login_params = record_login_stmt:bind_params({S.lastlogin_type, S.username_type})
|
local record_login_params = record_login_stmt:bind_params({S.lastlogin_type, S.username_type})
|
||||||
thismod.record_login_params = record_login_params
|
thismod.record_login_params = record_login_params
|
||||||
|
|
||||||
|
local enumerate_auths_query = 'SELECT ' .. S.username .. ',' .. S.password .. ',' .. S.privs ..
|
||||||
|
',' .. S.lastlogin .. ' FROM ' .. tables.auths.name
|
||||||
|
|
||||||
thismod.auth_handler = {
|
thismod.auth_handler = {
|
||||||
get_auth = function(name)
|
get_auth = function(name)
|
||||||
assert(type(name) == 'string')
|
assert(type(name) == 'string')
|
||||||
@ -275,7 +278,7 @@ do
|
|||||||
return {
|
return {
|
||||||
password = password,
|
password = password,
|
||||||
privileges = privs,
|
privileges = privs,
|
||||||
last_login = lastlogin
|
last_login = tonumber(lastlogin)
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
create_auth = function(name, password, reason)
|
create_auth = function(name, password, reason)
|
||||||
@ -356,6 +359,22 @@ do
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
end,
|
||||||
|
enumerate_auths = function()
|
||||||
|
conn:query(enumerate_auths_query)
|
||||||
|
local res = conn:use_result()
|
||||||
|
return function()
|
||||||
|
local row = res:fetch('n')
|
||||||
|
if not row then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local username, password, privs_str, lastlogin = unpack(row)
|
||||||
|
return username, {
|
||||||
|
password = password,
|
||||||
|
privileges = minetest.string_to_privs(privs_str),
|
||||||
|
last_login = tonumber(lastlogin)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user