iteration

This commit is contained in:
Layla 2023-10-08 05:11:52 -04:00
parent f9ae7618c9
commit f17190bbc9

View File

@ -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