This commit is contained in:
1 parent
4cce5754d3
commit
0f777d3e68
8 files changed
+333
-213
No files matched your search
@@ -3,42 +3,45 @@ const commonname = document.querySelector("#commonname");
|
||||
const organizationname = document.querySelector("#organizationname");
|
||||
const password = document.querySelector("#password");
|
||||
const organizationunit = document.querySelector("#organizationunit");
|
||||
const createcert = document.querySelector("#createcert");
|
||||
const create_certificate_form = document.querySelector(
|
||||
"#create_certificate_form",
|
||||
);
|
||||
|
||||
createcert.addEventListener("click", () => {
|
||||
const domainValue = domain.value;
|
||||
const commonnameValue = commonname.value;
|
||||
const organizationnameValue = organizationname.value;
|
||||
const passwordValue = password.value;
|
||||
const organizationunitValue = organizationunit.value;
|
||||
create_certificate_form.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const domainValue = domain.value;
|
||||
const commonnameValue = commonname.value;
|
||||
const organizationnameValue = organizationname.value;
|
||||
const passwordValue = password.value;
|
||||
const organizationunitValue = organizationunit.value;
|
||||
|
||||
fetch(window.location.origin + "/api/certs/create", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
dns: [domainValue],
|
||||
commonname: commonnameValue,
|
||||
organizationname: [organizationnameValue],
|
||||
organizationunit: [organizationunitValue],
|
||||
password: passwordValue,
|
||||
}),
|
||||
fetch(window.location.origin + "/api/certs/create", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
dns: [domainValue],
|
||||
commonname: commonnameValue,
|
||||
organizationname: [organizationnameValue],
|
||||
organizationunit: [organizationunitValue],
|
||||
password: passwordValue,
|
||||
}),
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => {
|
||||
if (jsondata.status === "success") {
|
||||
getCerts();
|
||||
var createmodal = bootstrap.Modal.getOrCreateInstance(
|
||||
document.getElementById("create_certificate"),
|
||||
);
|
||||
createmodal.hide();
|
||||
alert("Certificate created successfully");
|
||||
} else {
|
||||
alert("Failed to create certificate:", jsondata.error);
|
||||
}
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => {
|
||||
if (jsondata.status === "success") {
|
||||
getCerts();
|
||||
var createmodal = bootstrap.Modal.getOrCreateInstance(
|
||||
document.getElementById("create_certificate"),
|
||||
);
|
||||
createmodal.hide();
|
||||
alert("Certificate created successfully");
|
||||
} else {
|
||||
alert("Failed to create certificate:", jsondata.error);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
alert("An error occurred:", error);
|
||||
});
|
||||
.catch((error) => {
|
||||
alert("An error occurred:", error);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user