From d820a7a4f5a86eb6c7e5038d81a75853839689e9 Mon Sep 17 00:00:00 2001 From: Dorian Wouters Date: Sat, 3 Jun 2017 23:28:44 -0400 Subject: [PATCH] Return the userid in get_auth --- init.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 1e7a81d..5d85313 100644 --- a/init.lua +++ b/init.lua @@ -87,12 +87,12 @@ do end local S = tables.auths.schema - local get_auth_stmt = conn:prepare('SELECT ' .. S.password .. ',' .. S.privs .. ',' .. - S.lastlogin .. ' FROM ' .. tables.auths.name .. ' WHERE ' .. S.username .. '=?') + local get_auth_stmt = conn:prepare('SELECT ' .. S.userid .. ',' .. S.password .. ',' .. S.privs .. + ',' .. S.lastlogin .. ' FROM ' .. tables.auths.name .. ' WHERE ' .. S.username .. '=?') thismod.get_auth_stmt = get_auth_stmt local get_auth_params = get_auth_stmt:bind_params({S.username_type}) thismod.get_auth_params = get_auth_params - local get_auth_results = get_auth_stmt:bind_result({S.password_type, S.privs_type, + local get_auth_results = get_auth_stmt:bind_result({S.userid_type, S.password_type, S.privs_type, S.lastlogin_type}) thismod.get_auth_results = get_auth_results @@ -156,8 +156,8 @@ do minetest.log('warning', modname .. ": get_auth(" .. name .. "): multiples lines were" .. " returned") end - local password, privs_str, lastlogin = get_auth_results:get(1), get_auth_results:get(2), - get_auth_results:get(3) + local userid, password, privs_str, lastlogin = get_auth_results:get(1), + get_auth_results:get(2), get_auth_results:get(3), get_auth_results:get(4) local admin = (name == minetest.setting_get("name")) local privs if singleplayer or admin then @@ -176,6 +176,7 @@ do privs = minetest.string_to_privs(privs_str) end return { + userid = userid, password = password, privileges = privs, last_login = tonumber(lastlogin)