diff --git a/sftpgo-auth.php b/sftpgo-auth.php index 7ef7cb8..b52e7bf 100644 --- a/sftpgo-auth.php +++ b/sftpgo-auth.php @@ -5,29 +5,29 @@ const DEBUG = false; 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); exit(); } 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); $username = hashUsername($auth_data['username']); if (usernameExists($username) !== true) - deny(); + deny('This username doesn\'t exist.'); 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]; if (checkPassword($id, $auth_data['password']) !== true) - deny(); + deny('Wrong password.'); echo ' {