iteration
This commit is contained in:
		
							
								
								
									
										17
									
								
								lib/auth.lua
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								lib/auth.lua
									
									
									
									
									
								
							@ -49,6 +49,23 @@ function check_user_group(username, group)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function trueKeysToString(tbl)
 | 
			
		||||
    local result = ""
 | 
			
		||||
    local first = true
 | 
			
		||||
 | 
			
		||||
    for key, value in pairs(tbl) do
 | 
			
		||||
        if value == true then
 | 
			
		||||
            if not first then
 | 
			
		||||
                result = result .. ", "
 | 
			
		||||
            else
 | 
			
		||||
                first = false
 | 
			
		||||
            end
 | 
			
		||||
            result = result .. key
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return result
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function list_to_string(list)
 | 
			
		||||
    local str = ""
 | 
			
		||||
 | 
			
		||||
@ -101,7 +101,7 @@ elseif action == "group" then
 | 
			
		||||
 | 
			
		||||
    if subaction == "list" then
 | 
			
		||||
        local result = auth.list_user_groups(settings.get("auth.username"))
 | 
			
		||||
        io.write("Groups: " .. auth.list_to_string(result) .. "\n")
 | 
			
		||||
        io.write("Groups: " .. auth.trueKeysToString(result) .. "\n")
 | 
			
		||||
    elseif subaction == "add" then
 | 
			
		||||
        local target_user = args[3]
 | 
			
		||||
        local group = args[4]
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user