From 7a9fcc16769fba56ec9efd4558a5f4f7c3abfd9c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 24 Aug 2018 19:00:42 +0200 Subject: [PATCH 1/2] The "Wrong Token." message is shown whenever the token is wrong or not available. This commit adds more details into this message to help user's in their own troubleshooting. Signed-off-by: DL6ER --- scripts/pi-hole/php/auth.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php index 027220c9..ff236d2b 100644 --- a/scripts/pi-hole/php/auth.php +++ b/scripts/pi-hole/php/auth.php @@ -93,8 +93,16 @@ function check_csrf($token) { session_start(); } - if(!isset($_SESSION['token']) || empty($token) || !hash_equals($_SESSION['token'], $token)) { - log_and_die("Wrong token"); + if(!isset($_SESSION['token'])) { + log_and_die("Session expired! Please re-login on the Pi-hole dashboard."); + } + + if(empty($token)) { + log_and_die("Empty token! Check if cookies are enabled on your system."); + } + + if(!hash_equals($_SESSION['token'], $token)) { + log_and_die("Wrong token! Check if cookies are enabled on your system."); } } From d67f8c66eef52d8fe2347ec92645cd57d18713d0 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 24 Aug 2018 19:09:24 +0200 Subject: [PATCH 2/2] Wrong token is either when users try to do it via an old session or through a script. Hence, the message should tell the user to re-login Signed-off-by: DL6ER --- scripts/pi-hole/php/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php index ff236d2b..5d832a86 100644 --- a/scripts/pi-hole/php/auth.php +++ b/scripts/pi-hole/php/auth.php @@ -102,7 +102,7 @@ function check_csrf($token) { } if(!hash_equals($_SESSION['token'], $token)) { - log_and_die("Wrong token! Check if cookies are enabled on your system."); + log_and_die("Wrong token! Please re-login on the Pi-hole dashboard."); } }