small fix
This commit is contained in:
parent
8ab1a6b69f
commit
66b433950b
@ -29,7 +29,7 @@ class UserManager
|
|||||||
setcookie ("rememberMe", $this->setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), BASEDIR, $_SERVER['HTTP_HOST'], 1);
|
setcookie ("rememberMe", $this->setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), BASEDIR, $_SERVER['HTTP_HOST'], 1);
|
||||||
}
|
}
|
||||||
$_SESSION['user']['id'] = $user['user_id'];
|
$_SESSION['user']['id'] = $user['user_id'];
|
||||||
$page = "home";
|
$page = "";
|
||||||
if ($user["startPage"] == 1) {
|
if ($user["startPage"] == 1) {
|
||||||
$page = "dashboard";
|
$page = "dashboard";
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,17 @@ if (
|
|||||||
$ota = false;
|
$ota = false;
|
||||||
$userName = $_POST['username'];
|
$userName = $_POST['username'];
|
||||||
$userPassword = $_POST['password'];
|
$userPassword = $_POST['password'];
|
||||||
|
$rememberMe = (isset ($_POST['remember']) ? $_POST['remember'] : "");
|
||||||
$ota = $userManager->haveOtaEnabled($userName);
|
$ota = $userManager->haveOtaEnabled($userName);
|
||||||
|
if ($ota == "") {
|
||||||
|
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
|
||||||
|
header('Location: ' . BASEDIR . $landingPage);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
$_SESSION['USERNAME'] = $userName;
|
$_SESSION['USERNAME'] = $userName;
|
||||||
$_SESSION['PASSWORD'] = $userPassword;
|
$_SESSION['PASSWORD'] = $userPassword;
|
||||||
|
$_SESSION['REMEMBER'] = $rememberMe;
|
||||||
$_SESSION['OTA'] = $ota;
|
$_SESSION['OTA'] = $ota;
|
||||||
} else if (
|
} else if (
|
||||||
isset($_POST['otaCode']) &&
|
isset($_POST['otaCode']) &&
|
||||||
@ -28,10 +35,11 @@ if (
|
|||||||
$ota = $_SESSION['OTA'];
|
$ota = $_SESSION['OTA'];
|
||||||
$userName = $_SESSION['USERNAME'];
|
$userName = $_SESSION['USERNAME'];
|
||||||
$userPassword = $_SESSION['PASSWORD'];
|
$userPassword = $_SESSION['PASSWORD'];
|
||||||
|
$rememberMe = $_SESSION['REMEMBER'];
|
||||||
unset($_SESSION['OTA']);
|
unset($_SESSION['OTA']);
|
||||||
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 6); // 2 = 2*30sec clock tolerance
|
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 6); // 2 = 2*30sec clock tolerance
|
||||||
if ($checkResult) {
|
if ($checkResult) {
|
||||||
$landingPage = $userManager->login($userName, $userPassword);
|
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
|
||||||
header('Location: ' . BASEDIR . $landingPage);
|
header('Location: ' . BASEDIR . $landingPage);
|
||||||
echo 'OK';
|
echo 'OK';
|
||||||
} else {
|
} else {
|
||||||
|
17
app/controls/settings.php
Normal file
17
app/controls/settings.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
if (isset($_POST) && !empty($_POST)){
|
||||||
|
if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
|
||||||
|
$oldPassword = $_POST['oldPassword'];
|
||||||
|
$newPassword = $_POST['newPassword1'];
|
||||||
|
$newPassword2 = $_POST['newPassword2'];
|
||||||
|
UserManager::changePassword($oldPassword, $newPassword, $newPassword2);
|
||||||
|
header('Location: ' . BASEDIR . 'logout');
|
||||||
|
die();
|
||||||
|
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
|
||||||
|
$userName = $_POST['userName'];
|
||||||
|
$password = $_POST['userPassword'];
|
||||||
|
UserManager::createUser($userName, $password);
|
||||||
|
header('Location: ' . BASEDIR . 'setting');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
@ -78,7 +78,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||||
<h4 class="mb-4"><?php ?></h4>
|
<h4 class="mb-4"><?php ?></h4>
|
||||||
<img src="<?php echo ''?>" />
|
<img src="<?php echo $QRURL;?>" />
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -3,6 +3,7 @@ class Setting extends Template
|
|||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
global $userManager;
|
global $userManager;
|
||||||
global $langMng;
|
global $langMng;
|
||||||
|
|
||||||
@ -30,6 +31,20 @@ class Setting extends Template
|
|||||||
$users = $userManager->getUsers();
|
$users = $userManager->getUsers();
|
||||||
$template->prepare('users', $users);
|
$template->prepare('users', $users);
|
||||||
|
|
||||||
|
if ($userManager->getUserData('ota') == ''){
|
||||||
|
$ga = new PHPGangsta_GoogleAuthenticator();
|
||||||
|
$secret = $ga->createSecret();
|
||||||
|
$qrCodeUrl = $ga->getQRCodeGoogleUrl('SmartHome', $secret);
|
||||||
|
$oneCode = $ga->getCode($otaSecret);
|
||||||
|
$template->prepare('qrUrl', $qrCodeUrl);
|
||||||
|
$template->prepare('otaSecret', $otaSecret);
|
||||||
|
$template->prepare('otacode', $oneCode);
|
||||||
|
|
||||||
|
// echo "Secret is: ".$secret."\n\n";
|
||||||
|
// echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";
|
||||||
|
// echo "Checking Code '$oneCode' and Secret '$otaSecret':\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$template->render();
|
$template->render();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user