Don't require visiting /ht/ to enable SFTP access
This commit is contained in:
parent
a07baa7f62
commit
0e64d6e2b8
|
@ -171,9 +171,7 @@ function testNs($domain) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHt($username, $password) {
|
function testHt($username, $password) {
|
||||||
curlTest('/ht/', []);
|
define('TEST_CONTENT', 'test-' . bin2hex(random_bytes(16)));
|
||||||
|
|
||||||
define('TEST_CONTENT', 'test-' . random_bytes(4));
|
|
||||||
|
|
||||||
file_put_contents(sys_get_temp_dir() . '/index.html', TEST_CONTENT);
|
file_put_contents(sys_get_temp_dir() . '/index.html', TEST_CONTENT);
|
||||||
|
|
||||||
|
|
|
@ -128,13 +128,14 @@ if (isset($_SESSION['id'])) {
|
||||||
|
|
||||||
// Enable not already enabled services for this user
|
// Enable not already enabled services for this user
|
||||||
$user_services = array_filter(explode(',', query('select', 'users', ['id' => $_SESSION['id']], 'services')[0]));
|
$user_services = array_filter(explode(',', query('select', 'users', ['id' => $_SESSION['id']], 'services')[0]));
|
||||||
if (in_array(SERVICE, SERVICES_USER, true) AND !in_array(SERVICE, $user_services, true) AND CONF['common']['services'][SERVICE] === 'enabled') {
|
foreach (SERVICES_USER as $service)
|
||||||
$user_services[] = SERVICE;
|
if (!in_array($service, $user_services, true) AND CONF['common']['services'][$service] === 'enabled') {
|
||||||
|
$user_services[] = $service;
|
||||||
|
|
||||||
DB->prepare('UPDATE users SET services = :services WHERE id = :id')
|
DB->prepare('UPDATE users SET services = :services WHERE id = :id')
|
||||||
->execute([':services' => implode(',', $user_services), ':id' => $_SESSION['id']]);
|
->execute([':services' => implode(',', $user_services), ':id' => $_SESSION['id']]);
|
||||||
|
|
||||||
if (SERVICE === 'ht')
|
if ($service === 'ht')
|
||||||
htSetupUserFs($_SESSION['id']);
|
htSetupUserFs($_SESSION['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue