2020-05-16 15:18:27 +00:00
|
|
|
<?php
|
|
|
|
if (isset($_POST) && !empty($_POST)){
|
2020-10-17 16:03:55 +00:00
|
|
|
$userManager = new UserManager();
|
2020-05-16 15:18:27 +00:00
|
|
|
if (isset($_POST['submitPasswordChange']) && $_POST['submitPasswordChange'] != "") {
|
|
|
|
$oldPassword = $_POST['oldPassword'];
|
|
|
|
$newPassword = $_POST['newPassword1'];
|
|
|
|
$newPassword2 = $_POST['newPassword2'];
|
2020-10-17 16:03:55 +00:00
|
|
|
$userManager->changePassword($oldPassword, $newPassword, $newPassword2);
|
2020-05-16 15:18:27 +00:00
|
|
|
header('Location: ' . BASEURL . 'logout');
|
|
|
|
die();
|
|
|
|
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
|
|
|
|
$userName = $_POST['userName'];
|
|
|
|
$password = $_POST['userPassword'];
|
2020-10-17 16:03:55 +00:00
|
|
|
$email = $_POST['userEmail'];
|
|
|
|
$userManager->createUser($userName, $password, $email);
|
2020-05-16 15:18:27 +00:00
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
|
|
|
} else if (isset($_POST['submitEnableOta']) && $_POST['submitEnableOta'] != "") {
|
2020-05-16 23:27:06 +00:00
|
|
|
$otaCode = $_POST['otaCode'];
|
|
|
|
$otaSecret = $_POST['otaSecret'];
|
2020-05-16 15:18:27 +00:00
|
|
|
|
|
|
|
$ga = new PHPGangsta_GoogleAuthenticator();
|
|
|
|
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
|
|
|
|
if ($checkResult) {
|
2020-10-17 16:03:55 +00:00
|
|
|
$userManager->setOta($otaCode, $otaSecret);
|
2020-05-16 15:18:27 +00:00
|
|
|
}
|
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2020-10-17 16:03:55 +00:00
|
|
|
} else if (isset ($_POST['userPermission']) && !empty ($_POST['userID'])) {
|
|
|
|
$userManager->setUserDataAdmin("permission", $_POST['userPermission'], $_POST['userID']);
|
|
|
|
header('Location: ' . BASEURL . 'setting');
|
|
|
|
die();
|
2020-05-16 15:18:27 +00:00
|
|
|
}
|
|
|
|
}
|