iteration
This commit is contained in:
parent
f9ae7618c9
commit
f17190bbc9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user