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);
|
||||
}
|
||||
$_SESSION['user']['id'] = $user['user_id'];
|
||||
$page = "home";
|
||||
$page = "";
|
||||
if ($user["startPage"] == 1) {
|
||||
$page = "dashboard";
|
||||
}
|
||||
|
@ -11,10 +11,17 @@ if (
|
||||
$ota = false;
|
||||
$userName = $_POST['username'];
|
||||
$userPassword = $_POST['password'];
|
||||
$rememberMe = (isset ($_POST['remember']) ? $_POST['remember'] : "");
|
||||
$ota = $userManager->haveOtaEnabled($userName);
|
||||
if ($ota == "") {
|
||||
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
|
||||
header('Location: ' . BASEDIR . $landingPage);
|
||||
die();
|
||||
}
|
||||
|
||||
$_SESSION['USERNAME'] = $userName;
|
||||
$_SESSION['PASSWORD'] = $userPassword;
|
||||
$_SESSION['REMEMBER'] = $rememberMe;
|
||||
$_SESSION['OTA'] = $ota;
|
||||
} else if (
|
||||
isset($_POST['otaCode']) &&
|
||||
@ -28,10 +35,11 @@ if (
|
||||
$ota = $_SESSION['OTA'];
|
||||
$userName = $_SESSION['USERNAME'];
|
||||
$userPassword = $_SESSION['PASSWORD'];
|
||||
$rememberMe = $_SESSION['REMEMBER'];
|
||||
unset($_SESSION['OTA']);
|
||||
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 6); // 2 = 2*30sec clock tolerance
|
||||
if ($checkResult) {
|
||||
$landingPage = $userManager->login($userName, $userPassword);
|
||||
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
|
||||
header('Location: ' . BASEDIR . $landingPage);
|
||||
echo 'OK';
|
||||
} 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();
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="col-md-9 main-body">
|
||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||
<h4 class="mb-4">
|
||||
<h4 class="mb-4">
|
||||
<?php $LANGMNG->echo('t_pageAfterLogIn') ?>
|
||||
</h4>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
@ -61,27 +61,27 @@
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_oldPassword') ?>:</div>
|
||||
<input type="password" class="input" name="oldPassword" value="" data-cip-id="cIPJQ342845639">
|
||||
<input type="password" class="input" name="oldPassword" value="" data-cip-id="cIPJQ342845639">
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_newPassword') ?>:</div>
|
||||
<input type="password" class="input" name="newPassword1" value="" data-cip-id="cIPJQ342845639">
|
||||
<input type="password" class="input" name="newPassword1" value="" data-cip-id="cIPJQ342845639">
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_newPassword') ?>:</div>
|
||||
<input type="password" class="input" name="newPassword2" value="" data-cip-id="cIPJQ342845639">
|
||||
<input type="password" class="input" name="newPassword2" value="" data-cip-id="cIPJQ342845639">
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" name="submitPasswordChange" class="button" value="Uložit">
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||
<h4 class="mb-4"><?php ?></h4>
|
||||
<img src="<?php echo ''?>" />
|
||||
<img src="<?php echo $QRURL;?>" />
|
||||
<form method="post">
|
||||
|
||||
</form>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-12 col-sm-9 mx-auto mt-4">
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_createuser') ?></h4>
|
||||
@ -104,20 +104,20 @@
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_userName') ?>:</div>
|
||||
<input type="text" class="input" name="userName" value="" data-cip-id="cIPJQ342845639">
|
||||
<input type="text" class="input" name="userName" value="" data-cip-id="cIPJQ342845639">
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_password') ?>:</div>
|
||||
<input type="password" class="input" name="userPassword" value="" data-cip-id="cIPJQ342845639">
|
||||
<input type="password" class="input" name="userPassword" value="" data-cip-id="cIPJQ342845639">
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" name="submitCreateUser" class="button" value="Uložit">
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<script src="./app/templates/js/setting.js"></script>
|
||||
<?php
|
||||
|
@ -3,6 +3,7 @@ class Setting extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
global $userManager;
|
||||
global $langMng;
|
||||
|
||||
@ -30,6 +31,20 @@ class Setting extends Template
|
||||
$users = $userManager->getUsers();
|
||||
$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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user