Fixed failure to break when checks fail

master
Keith Irwin 2021-10-14 17:15:36 -06:00
parent b44a66eefb
commit 78466a0285
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
1 changed files with 4 additions and 4 deletions

View File

@ -72,7 +72,7 @@ app.get('/', async (req,res) => {
// Check if host exists
if (line.includes(`# ${hostname}.`)) {
console.log(`Host already exists for ${hostname}`)
res.sendStatus(500)
res.sendStatus(500); return
}
found_usernames.push(line.split('.').slice(-2,-1)[0])
}
@ -87,16 +87,16 @@ app.get('/', async (req,res) => {
if (!found_ipv4s.every((found_ipv4) =>
found_ipv4.toString().includes(`${IPV4_NET}.${subnet}.`))) {
console.log(`Found unmatching IPv4 address subnets for ${requester}: ${found_ipv4s}`)
res.sendStatus(500)
res.sendStatus(500); return
} else if (!found_ipv6s.every((found_ipv6) =>
found_ipv6.toString().includes(`${IPV6_NET}:${subnet}:`))) {
console.log(`Found unmatching IPv6 address subnets for ${requester}: ${found_ipv6s}`)
res.sendStatus(500)
res.sendStatus(500); return
// Check that all usernames are correct or error out
// https://stackoverflow.com/a/35568895
} else if (!found_usernames.every( (v,i,r) => v === r[0] )) {
console.log(`Found unmatching usernames for ${requester}: ${found_usernames.toString()}`)
res.sendStatus(500)
res.sendStatus(500); return
// Everything looks good! Proceed
} else {