Skip to content

Commit

Permalink
fix: handling hostPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jan 8, 2024
1 parent 1081e5b commit fa105b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class CoCreateAcme {
expires = expires.notAfter;
this.setCertificate(host, expires, organization_id, hostKeyPath, cert, key)

console.log(`saving host: ${host} at postion: ${hostPosition}`)

this.crud.send({
method: 'object.update',
host,
Expand All @@ -192,6 +194,7 @@ class CoCreateAcme {

async getCertificate(host, organization_id) {
const hostKeyPath = keyPath + host + '/';
let hostPosition

if (!organization_id) {
let org = await this.crud.getHost(host)
Expand All @@ -207,7 +210,6 @@ class CoCreateAcme {
return false

if (organization.host) {
let hostPosition
for (let i = 0; i < organization.host.length; i++) {
if (organization.host[i].name === host) {
hostPosition = i
Expand All @@ -223,7 +225,7 @@ class CoCreateAcme {
}
}

if (hostPosition >= 0)
if (!hostPosition && hostPosition !== 0)
return false
}

Expand Down

0 comments on commit fa105b1

Please sign in to comment.