mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Conditional HTTPS hint on login page (#2730)
This commit is contained in:
@@ -26,8 +26,8 @@ mg.include('scripts/pi-hole/lua/header.lp','r')
|
||||
<div class="text-center form-group has-error" id="dns-failure-label" style="display: none;">
|
||||
<label>DNS Server failure detected, log in to see Pi-hole diagnosis messages</label>
|
||||
</div>
|
||||
<div class="text-center form-group has-error" id="dns-failure-label" style="display: <? if is_secure then ?>none<? else ?>block<? end ?>;">
|
||||
<div class="box box-danger" id="insecure-box">
|
||||
<div class="text-center form-group has-error" id="insecure-box" style="display: none;">
|
||||
<div class="box box-danger">
|
||||
<div class="box-header with-border pointer no-user-select">
|
||||
<h3 class="box-title has-error control-label"><i class="fa fa-fw fa-triangle-exclamation"></i> Insecure network connection <i class="fa fa-fw fa-triangle-exclamation"></i></h3>
|
||||
</div>
|
||||
|
||||
@@ -112,15 +112,25 @@ $(function () {
|
||||
}).done(function (data) {
|
||||
if (data.session.valid === true) redirect();
|
||||
if (data.session.totp === true) $("#totp_input").removeClass("hidden");
|
||||
});
|
||||
|
||||
// Get information about HTTPS port and DNS status
|
||||
$.ajax({
|
||||
url: "/api/info/login",
|
||||
}).done(function (data) {
|
||||
if (data.dns === false) showDNSfailure();
|
||||
|
||||
// Generate HTTPS redirection link (only used if not already HTTPS)
|
||||
if (location.protocol !== "https:" && data.https_port !== 0) {
|
||||
let url = "https://" + location.hostname;
|
||||
if (data.https_port !== 443) url += ":" + data.https_port;
|
||||
url += location.pathname + location.search + location.hash;
|
||||
|
||||
$("#https-link").attr("href", url);
|
||||
$("#insecure-box").show();
|
||||
}
|
||||
});
|
||||
|
||||
// Clear TOTP field
|
||||
$("#totp").val("");
|
||||
|
||||
// Generate HTTPS redirection link (only used if not already HTTPS)
|
||||
if (location.protocol !== "https:") {
|
||||
const url = "https:" + location.href.substring(location.protocol.length);
|
||||
$("#https-link").attr("href", url);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user