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