|
@@ -5,29 +5,29 @@ const DEBUG = false;
|
|
|
|
|
|
require 'router.php';
|
|
require 'router.php';
|
|
|
|
|
|
-function deny() {
|
|
|
|
- !DEBUG or file_put_contents(ROOT_PATH . '/db/debug.txt', ob_get_contents());
|
|
|
|
|
|
+function deny($reason) {
|
|
|
|
+ !DEBUG or file_put_contents(ROOT_PATH . '/db/debug.txt', ob_get_contents() . $reason . LF);
|
|
http_response_code(403);
|
|
http_response_code(403);
|
|
exit();
|
|
exit();
|
|
}
|
|
}
|
|
|
|
|
|
if (CONF['common']['services']['ht'] !== 'enabled')
|
|
if (CONF['common']['services']['ht'] !== 'enabled')
|
|
- deny();
|
|
|
|
|
|
+ deny('Service not enabled.');
|
|
|
|
|
|
$auth_data = json_decode(file_get_contents('php://input'), true, flags: JSON_THROW_ON_ERROR);
|
|
$auth_data = json_decode(file_get_contents('php://input'), true, flags: JSON_THROW_ON_ERROR);
|
|
|
|
|
|
$username = hashUsername($auth_data['username']);
|
|
$username = hashUsername($auth_data['username']);
|
|
|
|
|
|
if (usernameExists($username) !== true)
|
|
if (usernameExists($username) !== true)
|
|
- deny();
|
|
|
|
|
|
+ deny('This username doesn\'t exist.');
|
|
|
|
|
|
if (!in_array('ht', explode(',', query('select', 'users', ['username' => $username], 'services')[0]), true))
|
|
if (!in_array('ht', explode(',', query('select', 'users', ['username' => $username], 'services')[0]), true))
|
|
- deny();
|
|
|
|
|
|
+ deny('Service not enabled for this user.');
|
|
|
|
|
|
$id = query('select', 'users', ['username' => $username], 'id')[0];
|
|
$id = query('select', 'users', ['username' => $username], 'id')[0];
|
|
|
|
|
|
if (checkPassword($id, $auth_data['password']) !== true)
|
|
if (checkPassword($id, $auth_data['password']) !== true)
|
|
- deny();
|
|
|
|
|
|
+ deny('Wrong password.');
|
|
|
|
|
|
echo '
|
|
echo '
|
|
{
|
|
{
|