Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cookie test to login page #362

Merged
merged 2 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/pi-hole/js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,27 @@ $(document).keypress(function(e) {
$("#loginform").submit();
}
});

function testCookies()
{
if (navigator.cookieEnabled)
{
return true;
}

// set and read cookie
document.cookie = "cookietest=1";
var ret = document.cookie.indexOf("cookietest=") !== -1;

// delete cookie
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";

return ret;
}

$(function() {
if(!testCookies() && $("#cookieInfo").length)
{
$("#cookieInfo").show();
}
});
2 changes: 1 addition & 1 deletion scripts/pi-hole/php/loginpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<div class="panel-title text-center"><span class="logo-lg" style="font-size: 25px;"><b>Pi</b>-hole</span></div>
<p class="login-box-msg">Sign in to start your session</p>
<div id="cookieInfo" class="panel-title text-center" style="color:#F00; font-size: 150%" hidden>Verify that cookies are allowed for <tt><?php echo $_SERVER['HTTP_HOST']; ?></tt></div>
<?php if ($wrongpassword) { ?>
<div class="form-group has-error login-box-msg">
<label class="control-label"><i class="fa fa-times-circle-o"></i> Wrong password!</label>
Expand Down Expand Up @@ -54,7 +55,6 @@ class="fa <?php if ($wrongpassword) { ?>fa-minus<?php } else { ?>fa-plus<?php }
</div>
</div>
</form>

</div>
</div>
</div>