servnest/sftpgo-auth.php

29 lines
741 B
PHP
Raw Normal View History

2022-05-19 14:59:32 +00:00
<?php
require 'router.php';
2022-05-19 14:59:32 +00:00
2022-11-26 20:45:48 +00:00
$auth_data = json_decode(file_get_contents('php://input'), true);
2022-05-19 14:59:32 +00:00
$username = hashUsername($auth_data['username']);
2022-11-26 20:45:48 +00:00
$id = query('select', 'users', ['username' => $username], 'id')[0];
if (usernameExists($username) === true AND checkPassword($id, $auth_data['password']) === true) {
2022-06-28 20:08:34 +00:00
echo '
{
"status": 1,
2022-11-26 20:45:48 +00:00
"username": ' . json_encode($auth_data['username']) . ',
"home_dir": "' . CONF['ht']['ht_path'] . '/' . $id . '",
"quota_size": ' . ((query('select', 'users', ['id' => $id], 'type')[0] === 'approved') ? CONF['ht']['user_quota_approved'] : CONF['ht']['user_quota_testing']) . ',
2022-06-28 20:08:34 +00:00
"permissions": {
"/": [
"*"
]
}
}
';
2022-05-19 14:59:32 +00:00
http_response_code(200);
} else {
http_response_code(403);
}