servnest/sftpgo-auth.php
2022-11-26 21:45:48 +01:00

26 lines
736 B
PHP

<?php
require 'router.php';
$auth_data = json_decode(file_get_contents('php://input'), true);
$internal_username = hash('sha256', $auth_data['username']);
if (userExist($internal_username) === true AND checkPassword($internal_username, $auth_data['password']) === true) {
echo '
{
"status": 1,
"username": ' . json_encode($auth_data['username']) . ',
"home_dir": "' . CONF['ht']['ht_path'] . '/' . $internal_username . '",
"quota_size": ' . ((query('select', 'users', ['username' => $internal_username], 'type')[0] === 'trusted') ? CONF['ht']['user_quota_trusted'] : CONF['ht']['user_quota_testing']) . ',
"permissions": {
"/": [
"*"
]
}
}
';
http_response_code(200);
} else {
http_response_code(403);
}