From 050af178881a04bfc2f5afd4fc06cf1116bad2ff Mon Sep 17 00:00:00 2001 From: leiweibau <105860611+leiweibau@users.noreply.github.com> Date: Thu, 4 Aug 2022 21:58:59 +0200 Subject: [PATCH] Add Remenber Password tested and should work now --- front/index.php | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/front/index.php b/front/index.php index 7789ccd6..60da5b2f 100644 --- a/front/index.php +++ b/front/index.php @@ -1,8 +1,9 @@ - pass and set initial cookie if ($Pia_Password == hash('sha256',$_POST["loginpassword"])) + { + header('Location: /pialert/devices.php'); + $_SESSION["login"] = 1; + if (isset($_POST['PWRemember'])) {setcookie("PiAler_SaveLogin", hash('sha256',$_POST["loginpassword"]), time()+604800);} + } + +// active Session or valid cookie (cookie not extends) +if (($_SESSION["login"] == 1) || ($Pia_Password == $_COOKIE["PiAler_SaveLogin"])) { header('Location: /pialert/devices.php'); $_SESSION["login"] = 1; } -if ($_SESSION["login"] == 1) - { - header('Location: /pialert/devices.php'); - } - +// no active session, cookie not checked if ($_SESSION["login"] != 1) { if (file_exists('../db/setting_darkmode')) {$ENABLED_DARKMODE = True;} if ($Pia_Password == '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92') { $login_info = 'Defaultpassword "123456" is still active'; $login_mode = 'danger'; + $login_display_mode = 'display: block;'; $login_headline = 'Password Alert!'; $login_icon = 'fa-ban'; } else { $login_mode = 'info'; + $login_display_mode = 'display: none;'; $login_headline = 'Password Information'; $login_icon = 'fa-info'; } @@ -122,24 +130,32 @@ if ($ENABLED_DARKMODE === True) {
./reset_password.sh