Skip to content

Commit

Permalink
Merge pull request #362 from pi-hole/tweak/cookieTest
Browse files Browse the repository at this point in the history
Add cookie test to login page
  • Loading branch information
DL6ER authored Jan 16, 2017
2 parents 2f33443 + f840caf commit 15f1a4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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>

0 comments on commit 15f1a4e

Please sign in to comment.