Fix sftpgo-auth.php

This commit is contained in:
Miraty 2023-03-09 14:40:26 +01:00
parent ca0759c8ab
commit 887ddd2474

View file

@ -2,13 +2,26 @@
require 'router.php';
function deny() {
http_response_code(403);
exit();
}
if (CONF['common']['services']['ht'] !== 'enabled')
deny();
$auth_data = json_decode(file_get_contents('php://input'), true);
$username = hashUsername($auth_data['username']);
if (usernameExists($username) !== true)
deny();
$id = query('select', 'users', ['username' => $username], 'id')[0];
if (usernameExists($username) === true AND checkPassword($id, $auth_data['password']) === true) {
if (checkPassword($id, $auth_data['password']) !== true)
deny();
echo '
{
"status": 1,
@ -23,6 +36,4 @@ if (usernameExists($username) === true AND checkPassword($id, $auth_data['passwo
}
';
http_response_code(200);
} else {
http_response_code(403);
}