ui / setup wizard - use default HTTPS cert to avoid error with fetch calls, fix newsletter check validity and fix wrong url in the check handler

This commit is contained in:
fl0ppy-d1sk 2024-05-27 17:03:49 +02:00
parent 32d9be885f
commit 55c4edb6eb
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500
2 changed files with 63 additions and 58 deletions

View file

@ -577,7 +577,9 @@ def setup():
"REVERSE_PROXY_HOST": request.form["ui_host"],
"REVERSE_PROXY_URL": request.form["ui_url"] or "/",
"AUTO_LETS_ENCRYPT": request.form.get("auto_lets_encrypt", "no"),
"GENERATE_SELF_SIGNED_SSL": "yes" if request.form.get("auto_lets_encrypt", "no") == "no" else "no",
"USE_CUSTOM_SSL": "yes" if request.form.get("auto_lets_encrypt", "no") == "no" else "no",
"CUSTOM_SSL_CERT": "/var/cache/bunkerweb/misc/default-server-cert.pem" if request.form.get("auto_lets_encrypt", "no") == "no" else "",
"CUSTOM_SSL_KEY": "/var/cache/bunkerweb/misc/default-server-cert.key" if request.form.get("auto_lets_encrypt", "no") == "no" else "",
"INTERCEPTED_ERROR_CODES": "400 404 405 413 429 500 501 502 503 504",
"MAX_CLIENT_SIZE": "50m",
},

View file

@ -180,50 +180,6 @@
{% else %}
<h6 class="col-span-12 block text-left font-bold mb-4 mt-2">🧑‍🚀 An admin user already exists</h6>
{% endif %}
<h2 class="col-span-12 block text-left font-bold my-4 text-2xl">Newsletter</h2>
<!-- email inpt-->
<div class="flex flex-col relative col-span-12 mx-2 max-w-[400px] w-full">
<h5 class="text-base mb-1 transition duration-300 ease-in-out text-md font-bold m-0">Email</h5>
<label class="sr-only" for="newsletter-email">email</label>
<input tabindex="1"
type="email"
id="newsletter-email"
name="EMAIL"
class="col-span-12 disabled:opacity-75 focus:valid:border-green-500 focus:invalid:border-red-500 outline-none focus:border-primary text-sm leading-5.6 ease block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-4 py-2 font-normal text-gray-700 transition-all placeholder:text-gray-500"
placeholder="example@gmail.com"
value="" />
</div>
<!-- auto privacy policy-->
<div class="flex relative col-span-12 my-3 mx-2 max-w-[400px] w-full">
<label class="sr-only" for="newsletter-check">privacy policy</label>
<div data-checkbox-handler="newsletter-check"
class="relative mb-7 md:mb-0 z-10">
<input data-check
tabindex="1"
type="checkbox"
id="newsletter-check"
name="newsletter-check"
data-checked="false"
class="checkbox"
value="no" />
<svg data-checkbox-handler="newsletter-check"
class="pointer-events-none absolute fill-white left-0 top-0 translate-x-1 translate-y-2 h-3 w-3"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<path class="pointer-events-none" d="M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z">
</path>
</svg>
</div>
<h5 class="text-base mt-1 transition duration-300 ease-in-out text-md font-bold m-0 ml-2">
I've read and agree to the
<a class="privacy-link"
href="https://www.bunkerity.com/en/privacy-policy?utm_campaign=self&utm_source=ui"
target="_blank"
rel="noopener">privacy policy</a>
</h5>
</div>
<!-- end auto privacy policy-->
<!-- end email inpt-->
<h2 class="col-span-12 block text-left font-bold mb-4 mt-2 text-2xl">Settings</h2>
<!-- ui host-->
<div class="flex flex-col relative col-span-12 my-3 mx-2 max-w-[400px] w-full">
@ -322,16 +278,60 @@
<p class="family-text text-center text-sm md:text-base break-words w-full px-4"
data-resume>https://</p>
</div>
<div class="col-span-12 flex justify-center">
<button tabindex="2"
type="submit"
id="setup-button"
name="setup-button"
value="setup"
class="tracking-wide my-4 inline-block px-6 py-3 font-bold text-center text-white uppercase align-middle transition-all rounded-lg cursor-pointer bg-primary hover:bg-primary/80 focus:bg-primary/80 leading-normal text-sm ease-in shadow-xs bg-150 bg-x-25 hover:-translate-y-px active:opacity-85 hover:shadow-md">
Setup
</button>
<h2 class="col-span-12 block text-left font-bold my-4 text-2xl">Newsletter</h2>
<!-- email inpt-->
<div class="flex flex-col relative col-span-12 mx-2 max-w-[400px] w-full">
<h5 class="text-base mb-1 transition duration-300 ease-in-out text-md font-bold m-0">Email</h5>
<label class="sr-only" for="newsletter-email">email</label>
<input tabindex="1"
type="email"
id="newsletter-email"
name="EMAIL"
class="col-span-12 disabled:opacity-75 focus:valid:border-green-500 focus:invalid:border-red-500 outline-none focus:border-primary text-sm leading-5.6 ease block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-4 py-2 font-normal text-gray-700 transition-all placeholder:text-gray-500"
placeholder="example@gmail.com"
value="" />
</div>
<!-- auto privacy policy-->
<div class="flex relative col-span-12 my-3 mx-2 max-w-[400px] w-full">
<label class="sr-only" for="newsletter-check">privacy policy</label>
<div data-checkbox-handler="newsletter-check"
class="relative mb-7 md:mb-0 z-10">
<input data-check
tabindex="1"
type="checkbox"
id="newsletter-check"
name="newsletter-check"
data-checked="false"
class="checkbox"
value="no" />
<svg data-checkbox-handler="newsletter-check"
class="pointer-events-none absolute fill-white left-0 top-0 translate-x-1 translate-y-2 h-3 w-3"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<path class="pointer-events-none" d="M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z">
</path>
</svg>
</div>
<h5 class="text-base mt-1 transition duration-300 ease-in-out text-md font-bold m-0 ml-2">
I've read and agree to the
<a class="privacy-link"
href="https://www.bunkerity.com/en/privacy-policy?utm_campaign=self&utm_source=ui"
target="_blank"
rel="noopener">privacy policy</a>
</h5>
</div>
<!-- end auto privacy policy-->
<!-- end email inpt-->
<div class="col-span-12 flex justify-center">
<button tabindex="2"
type="submit"
id="setup-button"
name="setup-button"
value="setup"
class="tracking-wide my-4 inline-block px-6 py-3 font-bold text-center text-white uppercase align-middle transition-all rounded-lg cursor-pointer bg-primary hover:bg-primary/80 focus:bg-primary/80 leading-normal text-sm ease-in shadow-xs bg-150 bg-x-25 hover:-translate-y-px active:opacity-85 hover:shadow-md">
Setup
</button>
</div>
</form>
</div>
</div>
@ -370,7 +370,7 @@
e.preventDefault();
this.updateCheck("unknown");
// get resume
const api = `${location.protocol}://${this.servInp.value}/setup/check`;
const api = `https://${this.servInp.value}/setup/check`;
fetch(api)
.then((res) => {
this.updateCheck("success");
@ -592,13 +592,16 @@
this.hideErrMsg();
// Send email
if(this.checkEmailInp.checked && this.checkEmailInp.checkValidity()) {
if(this.checkEmailInp.checked && this.emailInp.checkValidity()) {
this.subscribe();
}
// send form and wait for response
let api = `https://${this.servInp.value}${this.urlInp.value}`;
let api = `https://${this.servInp.value}`;
if (!this.urlInp.value.startsWith("/")) {
api = `${api}/`;
}
api = `${api}${this.urlInp.value}`;
if (!api.endsWith("/")) {
api = `${api}/`;
}