PHP_SMART_HOME_V3/app/controllers/settingController.php

30 lines
1.1 KiB
PHP
Raw Normal View History

2019-10-30 14:18:29 +00:00
<?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);
2020-04-28 09:52:14 +00:00
header('Location: ' . BASEURL . 'logout');
2019-10-30 14:18:29 +00:00
die();
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
$userName = $_POST['userName'];
$password = $_POST['userPassword'];
UserManager::createUser($userName, $password);
2020-04-28 09:52:14 +00:00
header('Location: ' . BASEURL . 'setting');
2019-10-30 14:18:29 +00:00
die();
} else if (isset($_POST['submitEnableOta']) && $_POST['submitEnableOta'] != "") {
echo $otaCode = $_POST['otaCode'];
echo $otaSecret = $_POST['otaSecret'];
$ga = new PHPGangsta_GoogleAuthenticator();
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
if ($checkResult) {
UserManager::setOta($otaCode, $otaSecret);
}
2020-04-28 09:52:14 +00:00
header('Location: ' . BASEURL . 'setting');
2019-10-30 14:18:29 +00:00
die();
}
}