diff --git a/tg_server/tg_server.lua b/tg_server/tg_server.lua index 1cb5ec2..313c647 100644 --- a/tg_server/tg_server.lua +++ b/tg_server/tg_server.lua @@ -31,24 +31,21 @@ end local function validate_key(card_holder, card_clearance, random_chars) local card_hash = hash(card_holder..','..card_clearance..','..random_chars) local key_file = fs.open(dir..config.key_file, 'r') - local card_authentic = false while true do local trusted_hash = key_file.readLine() if trusted_hash == card_hash then print("Valid card "..card_hash) - card_authentic = true + key_file.close() return true, card_hash end - if not line then break end -- Stop when EOF reached + if not trusted_hash then break end -- Stop when EOF reached end key_file.close() - if card_authentic == false then - print("Unknown card "..card_hash) - return false - end + print("Unknown card "..card_hash) + return false end if args[1] == "serve" then