Fixed crash when user tries to add existing hostname

master
Keith Irwin 2021-12-07 09:05:54 -07:00
parent cf40f571aa
commit 12c24d6571
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
1 changed files with 1 additions and 1 deletions

View File

@ -47,12 +47,12 @@ module.exports = async (req, res) => {
}
// Check if new peer already exists
const domain = `${new_hostname}.${user.name}.${env.TLD}`
if (user.peers.map((peer) => peer.name).includes(new_hostname)) {
console.log(`Host already exists for ${domain}`)
return res.sendStatus(409)
}
const domain = `${new_hostname}.${user.name}.${env.TLD}`
// Find next available host part
const used_ipv4_hosts = user.peers