args = { ... } if args[1] == nil then io.write("Usage: auth \n") return end local action = args[1] if action == "login" then io.write("Username: ") local username = io.read() io.write("Password: ") local password = read("*") if login(username, password) then io.write("Logged in as " .. username .. "\n") end elseif action == "logout" then auth.logout() return elseif action == "register" then io.write("Username: ") local username = io.read() io.write("Password: ") local password = read("*") io.write("Confirm Password: ") local confirm_password = read("*") if password ~= confirm_password then io.write("Passwords do not match\n") return end auth.register(username, password) elseif action == "group" then local subaction = args[2] if subaction == nil then io.write("Usage: auth group \n") return end if subaction == "list" then local result = auth.list_user_groups(settings.get("auth.username")) io.write("Groups: " .. auth.trueKeysToString(result) .. "\n") elseif subaction == "add" then local target_user = args[3] local group = args[4] if target_user == nil or group == nil then io.write("Usage: auth group add \n") return end local result = auth.add_user_to_group(target_user, group) elseif subaction == "check" then local target_user = args[3] local group = args[4] if target_user == nil or group == nil then io.write("Usage: auth group check \n") return end local result = auth.check_user_in_group(target_user, group) if result then io.write("User " .. target_user .. " is in group " .. group .. "\n") else io.write("User " .. target_user .. " is not in group " .. group .. "\n") end else io.write("Usage: auth group \n") return end end