diff --git a/packages/auth_server.lua b/packages/auth_server.lua index 2679ecc..d9bb380 100644 --- a/packages/auth_server.lua +++ b/packages/auth_server.lua @@ -1,6 +1,6 @@ -data = { +local data = { users = { ["admin"] = { password = "admin" @@ -53,6 +53,14 @@ function log(str) io.write("[" .. os.time() .. "] " .. str .. "\n") end +function countElements(table) + local count = 0 + for key, value in pairs(table) do + count = count + 1 + end + return count +end + load_data() math.randomseed(os.time()) @@ -77,7 +85,7 @@ while true do password = convert_password(request.password) } - local user_count = #data.users + local user_count = countElements(data.users) if user_count == 1 then data.users[request.username].groups = { ["admin"] = true