Compare commits
2 commits
da130e5855
...
7a64db0540
Author | SHA1 | Date | |
---|---|---|---|
7a64db0540 | |||
9f5336c76e |
9 changed files with 130 additions and 131 deletions
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"require": {
|
||||
"flashwave/index": "^0.2410",
|
||||
"flashii/apii": "^0.2",
|
||||
"ramsey/uuid": "^4.7",
|
||||
"sentry/sdk": "^4.0",
|
||||
"nesbot/carbon": "^3.7"
|
||||
|
|
141
composer.lock
generated
141
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c55991a4602fd82deb63b990f03b7455",
|
||||
"content-hash": "714c9c35773e63de5f25ad797a2fe84e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
|
@ -135,13 +135,50 @@
|
|||
],
|
||||
"time": "2024-02-09T16:56:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "flashii/apii",
|
||||
"version": "v0.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://patchii.net/flashii/apii-php.git",
|
||||
"reference": "6a93d31375dd7e75ff9264f3024f2208ce602f49"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.12",
|
||||
"phpunit/phpunit": "^10.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flashii\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"bsd-3-clause-clear"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "flashwave",
|
||||
"email": "packagist@flash.moe",
|
||||
"homepage": "https://flash.moe",
|
||||
"role": "mom"
|
||||
}
|
||||
],
|
||||
"description": "Client library for the Flashii.net API.",
|
||||
"homepage": "https://api.flashii.net",
|
||||
"time": "2024-11-16T16:03:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "flashwave/index",
|
||||
"version": "v0.2410.51409",
|
||||
"version": "v0.2410.191603",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://patchii.net/flash/index.git",
|
||||
"reference": "c43c6eb334f85edf8fa7b5e4058b3ba35a27d960"
|
||||
"reference": "17cdb4d1c239241200d7e30968122a8cd8b26509"
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
|
@ -162,6 +199,14 @@
|
|||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Cache/ArrayCache/_ndx.php",
|
||||
"src/Cache/Memcached/_ndx.php",
|
||||
"src/Cache/Valkey/_ndx.php",
|
||||
"src/Db/MariaDb/_ndx.php",
|
||||
"src/Db/NullDb/_ndx.php",
|
||||
"src/Db/Sqlite/_ndx.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Index\\": "src"
|
||||
}
|
||||
|
@ -180,7 +225,7 @@
|
|||
],
|
||||
"description": "Composer package for the common library for my projects.",
|
||||
"homepage": "https://railgun.sh/index",
|
||||
"time": "2024-10-05T14:10:08+00:00"
|
||||
"time": "2024-10-19T16:04:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
|
@ -359,20 +404,20 @@
|
|||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "3.8.0",
|
||||
"version": "3.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f"
|
||||
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
|
||||
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
|
||||
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"carbonphp/carbon-doctrine-types": "*",
|
||||
"carbonphp/carbon-doctrine-types": "<100.0",
|
||||
"ext-json": "*",
|
||||
"php": "^8.1",
|
||||
"psr/clock": "^1.0",
|
||||
|
@ -461,7 +506,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-08-19T06:22:39+00:00"
|
||||
"time": "2024-11-07T17:46:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/clock",
|
||||
|
@ -951,16 +996,16 @@
|
|||
},
|
||||
{
|
||||
"name": "sentry/sentry",
|
||||
"version": "4.9.0",
|
||||
"version": "4.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/getsentry/sentry-php.git",
|
||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
|
||||
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -978,12 +1023,12 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.4",
|
||||
"guzzlehttp/promises": "^1.0|^2.0",
|
||||
"guzzlehttp/promises": "^2.0.3",
|
||||
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
|
||||
"monolog/monolog": "^1.6|^2.0|^3.0",
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpstan/phpstan": "^1.3",
|
||||
"phpunit/phpunit": "^8.5.14|^9.4",
|
||||
"phpunit/phpunit": "^8.5|^9.6",
|
||||
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
||||
"vimeo/psalm": "^4.17"
|
||||
},
|
||||
|
@ -1024,7 +1069,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/getsentry/sentry-php/issues",
|
||||
"source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
|
||||
"source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1036,20 +1081,20 @@
|
|||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2024-08-08T14:40:50+00:00"
|
||||
"time": "2024-11-06T07:44:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/clock",
|
||||
"version": "v7.1.1",
|
||||
"version": "v7.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/clock.git",
|
||||
"reference": "3dfc8b084853586de51dd1441c6242c76a28cbe7"
|
||||
"reference": "97bebc53548684c17ed696bc8af016880f0f098d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/clock/zipball/3dfc8b084853586de51dd1441c6242c76a28cbe7",
|
||||
"reference": "3dfc8b084853586de51dd1441c6242c76a28cbe7",
|
||||
"url": "https://api.github.com/repos/symfony/clock/zipball/97bebc53548684c17ed696bc8af016880f0f098d",
|
||||
"reference": "97bebc53548684c17ed696bc8af016880f0f098d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1094,7 +1139,7 @@
|
|||
"time"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/clock/tree/v7.1.1"
|
||||
"source": "https://github.com/symfony/clock/tree/v7.1.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1110,7 +1155,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-31T14:57:53+00:00"
|
||||
"time": "2024-09-25T14:20:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
|
@ -1181,16 +1226,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/mime",
|
||||
"version": "v7.1.5",
|
||||
"version": "v7.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/mime.git",
|
||||
"reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff"
|
||||
"reference": "caa1e521edb2650b8470918dfe51708c237f0598"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/mime/zipball/711d2e167e8ce65b05aea6b258c449671cdd38ff",
|
||||
"reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff",
|
||||
"url": "https://api.github.com/repos/symfony/mime/zipball/caa1e521edb2650b8470918dfe51708c237f0598",
|
||||
"reference": "caa1e521edb2650b8470918dfe51708c237f0598",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1245,7 +1290,7 @@
|
|||
"mime-type"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/mime/tree/v7.1.5"
|
||||
"source": "https://github.com/symfony/mime/tree/v7.1.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1261,20 +1306,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-20T08:28:38+00:00"
|
||||
"time": "2024-10-25T15:11:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v7.1.1",
|
||||
"version": "v7.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55"
|
||||
"reference": "85e95eeede2d41cd146146e98c9c81d9214cae85"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/47aa818121ed3950acd2b58d1d37d08a94f9bf55",
|
||||
"reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/85e95eeede2d41cd146146e98c9c81d9214cae85",
|
||||
"reference": "85e95eeede2d41cd146146e98c9c81d9214cae85",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1312,7 +1357,7 @@
|
|||
"options"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/options-resolver/tree/v7.1.1"
|
||||
"source": "https://github.com/symfony/options-resolver/tree/v7.1.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1328,7 +1373,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-31T14:57:53+00:00"
|
||||
"time": "2024-09-25T14:20:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
|
@ -1807,16 +1852,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v7.1.5",
|
||||
"version": "v7.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea"
|
||||
"reference": "b9f72ab14efdb6b772f85041fa12f820dee8d55f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/235535e3f84f3dfbdbde0208ede6ca75c3a489ea",
|
||||
"reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/b9f72ab14efdb6b772f85041fa12f820dee8d55f",
|
||||
"reference": "b9f72ab14efdb6b772f85041fa12f820dee8d55f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1881,7 +1926,7 @@
|
|||
"description": "Provides tools to internationalize your application",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/translation/tree/v7.1.5"
|
||||
"source": "https://github.com/symfony/translation/tree/v7.1.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -1897,7 +1942,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-16T06:30:38+00:00"
|
||||
"time": "2024-09-28T12:35:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation-contracts",
|
||||
|
@ -2047,16 +2092,16 @@
|
|||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v3.14.0",
|
||||
"version": "v3.14.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
|
||||
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
|
||||
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2110,7 +2155,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.14.0"
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.14.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2122,7 +2167,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T17:55:12+00:00"
|
||||
"time": "2024-11-07T12:36:22+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
namespace Mince;
|
||||
|
||||
use Index\Config\Fs\FsConfig;
|
||||
use Index\Db\DbTools;
|
||||
use Index\Db\DbBackends;
|
||||
|
||||
define('MCR_STARTUP', microtime(true));
|
||||
define('MCR_ROOT', __DIR__);
|
||||
|
@ -34,5 +34,5 @@ if($cfg->hasValues('sentry:dsn'))
|
|||
});
|
||||
})($cfg->scopeTo('sentry'));
|
||||
|
||||
$db = DbTools::create($cfg->getString('database:dsn', 'null:'));
|
||||
$db = DbBackends::create($cfg->getString('database:dsn', 'null:'));
|
||||
$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace Mince;
|
||||
|
||||
use Flashii\{FlashiiClient,FlashiiUrls};
|
||||
use Flashii\Credentials\MisuzuCredentials;
|
||||
use Index\CsrfToken;
|
||||
use Index\Http\Routing\HttpRouter;
|
||||
use Index\Templating\TplEnvironment;
|
||||
|
@ -10,17 +12,22 @@ require_once __DIR__ . '/../mince.php';
|
|||
|
||||
// replace this with id.flashii.net shit
|
||||
$authToken = (string)filter_input(INPUT_COOKIE, 'msz_auth');
|
||||
$authInfo = ChatAuth::attempt($cfg->scopeTo('cauth'), $authToken);
|
||||
|
||||
$flashii = new FlashiiClient('Mince', new MisuzuCredentials($authToken), new FlashiiUrls(
|
||||
$cfg->getString('apii:api', FlashiiUrls::PROD_API_URL),
|
||||
$cfg->getString('apii:id', FlashiiUrls::PROD_ID_URL)
|
||||
));
|
||||
$authInfo = $flashii->v1()->me();
|
||||
|
||||
$users = new Users($db);
|
||||
if($authInfo->success) {
|
||||
$users->syncChatUser($authInfo);
|
||||
$userInfo = $users->getUser($authInfo->user_id);
|
||||
if($authInfo !== null) {
|
||||
$users->syncApiUser($authInfo);
|
||||
$userInfo = $users->getUser($authInfo->getId());
|
||||
} else $userInfo = null;
|
||||
|
||||
$csrfp = new CsrfToken(
|
||||
$cfg->getString('csrfp:secret', 'wowof'),
|
||||
$authInfo->success ? $authToken : $_SERVER['REMOTE_ADDR']
|
||||
$authInfo === null ? $_SERVER['REMOTE_ADDR'] : $authToken
|
||||
);
|
||||
|
||||
$templating = new TplEnvironment(MCR_DIR_TPL, ['Mince'], debug: MCR_DEBUG);
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
namespace Mince;
|
||||
|
||||
use stdClass;
|
||||
use Index\Config\Config;
|
||||
|
||||
final class ChatAuth {
|
||||
public static function attempt(Config $config, string $cookie): object {
|
||||
if(!empty($cookie)) {
|
||||
$method = 'Misuzu';
|
||||
$signature = sprintf('verify#%s#%s#%s', $method, $cookie, $_SERVER['REMOTE_ADDR']);
|
||||
$signature = hash_hmac('sha256', $signature, $config->getString('secret'));
|
||||
|
||||
$login = curl_init($config->getString('endpoint'));
|
||||
curl_setopt_array($login, [
|
||||
CURLOPT_AUTOREFERER => false,
|
||||
CURLOPT_FAILONERROR => false,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query([
|
||||
'method' => $method,
|
||||
'token' => $cookie,
|
||||
'ipaddr' => $_SERVER['REMOTE_ADDR'],
|
||||
], '', '&', PHP_QUERY_RFC3986),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TCP_FASTOPEN => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 2,
|
||||
CURLOPT_MAXREDIRS => 2,
|
||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
CURLOPT_USERAGENT => 'Mince',
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'X-SharpChat-Signature: ' . $signature,
|
||||
],
|
||||
]);
|
||||
$userInfo = json_decode(curl_exec($login));
|
||||
curl_close($login);
|
||||
}
|
||||
|
||||
if(empty($userInfo->success)) {
|
||||
$userInfo = new stdClass;
|
||||
$userInfo->success = false;
|
||||
$userInfo->user_id = 0;
|
||||
$userInfo->username = 'Anonymous';
|
||||
$userInfo->colour_raw = 0x40000000;
|
||||
$userInfo->rank = 0;
|
||||
$userInfo->hierarchy = 0;
|
||||
$userInfo->perms = 0;
|
||||
}
|
||||
|
||||
return $userInfo;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ namespace Mince;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Flashii\V1\Users\V1User;
|
||||
use Index\CsrfToken;
|
||||
use Index\Http\Routing\{HttpGet,HttpMiddleware,HttpPost,RouteHandler,RouteHandlerTrait};
|
||||
use Index\Templating\TplEnvironment;
|
||||
|
@ -19,12 +20,12 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
private Authorisations $authorisations,
|
||||
private Verifications $verifications,
|
||||
private CsrfToken $csrfp,
|
||||
private object $authInfo
|
||||
private ?V1User $authInfo
|
||||
) {}
|
||||
|
||||
#[HttpMiddleware('/clients')]
|
||||
public function verifyRequest($response, $request) {
|
||||
if(!$this->authInfo->success)
|
||||
if($this->authInfo === null)
|
||||
return 403;
|
||||
|
||||
if($request->getMethod() === 'POST') {
|
||||
|
@ -66,7 +67,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
}
|
||||
|
||||
try {
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->user_id);
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->getId());
|
||||
$clients = iterator_to_array($this->authorisations->getAuthorisations($linkInfo));
|
||||
|
||||
$template->setVars([
|
||||
|
@ -81,7 +82,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
#[HttpPost('/clients/link')]
|
||||
#[UrlFormat('clients:link', '/clients/link')]
|
||||
public function postLink($response, $request) {
|
||||
if($this->accountLinks->checkHasLink($this->authInfo->user_id)) {
|
||||
if($this->accountLinks->checkHasLink($this->authInfo->getId())) {
|
||||
$response->redirect($this->urls->format('clients:index', ['error' => 'link:already']));
|
||||
return;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
}
|
||||
|
||||
$this->verifications->deleteVerification($verifyInfo);
|
||||
$this->accountLinks->createLink($this->authInfo->user_id, $verifyInfo);
|
||||
$this->accountLinks->createLink($this->authInfo->getId(), $verifyInfo);
|
||||
$this->authorisations->createAuthorisation($verifyInfo, grant: true);
|
||||
|
||||
$response->redirect($this->urls->format('clients:index'));
|
||||
|
@ -112,7 +113,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
#[HttpPost('/clients/unlink')]
|
||||
#[UrlFormat('clients:unlink', '/clients/unlink')]
|
||||
public function postUnlink($response) {
|
||||
$this->accountLinks->deleteLink(userInfo: $this->authInfo->user_id);
|
||||
$this->accountLinks->deleteLink(userInfo: $this->authInfo->getId());
|
||||
$response->redirect($this->urls->format('clients:index'));
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
return 404;
|
||||
|
||||
try {
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->user_id);
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->getId());
|
||||
} catch(RuntimeException $ex) {
|
||||
return 403;
|
||||
}
|
||||
|
@ -155,7 +156,7 @@ class ClientsRoutes implements RouteHandler, UrlSource {
|
|||
return 404;
|
||||
|
||||
try {
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->user_id);
|
||||
$linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->getId());
|
||||
} catch(RuntimeException $ex) {
|
||||
return 403;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace Mince;
|
||||
|
||||
use Flashii\V1\Users\V1User;
|
||||
use Index\Http\Routing\{HttpGet,RouteHandler,RouteHandlerTrait};
|
||||
use Index\Urls\{UrlFormat,UrlRegistry,UrlSource,UrlSourceTrait};
|
||||
use Index\Templating\TplEnvironment;
|
||||
|
@ -12,7 +13,7 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
|||
private TplEnvironment $templating,
|
||||
private UrlRegistry $urls,
|
||||
private Servers $servers,
|
||||
private object $userInfo,
|
||||
private ?V1User $authInfo,
|
||||
private string $loginUrl
|
||||
) {}
|
||||
|
||||
|
@ -27,7 +28,7 @@ class HomeRoutes implements RouteHandler, UrlSource {
|
|||
#[HttpGet('/login')]
|
||||
#[UrlFormat('login', '/login')]
|
||||
public function getLogin($response) {
|
||||
$response->redirect($this->userInfo->success ? $this->urls->format('index') : $this->loginUrl);
|
||||
$response->redirect($this->authInfo === null ? $this->loginUrl : $this->urls->format('index'));
|
||||
}
|
||||
|
||||
#[HttpGet('/downloads')]
|
||||
|
|
|
@ -6,6 +6,7 @@ use ImagickException;
|
|||
use ImagickPixel;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Flashii\V1\Users\V1User;
|
||||
use Index\{CsrfToken,XString};
|
||||
use Index\Http\Routing\{HttpGet,HttpMiddleware,HttpPost,RouteHandler,RouteHandlerTrait};
|
||||
use Index\Templating\TplEnvironment;
|
||||
|
@ -27,7 +28,7 @@ class SkinsRoutes implements RouteHandler, UrlSource {
|
|||
private Skins $skins,
|
||||
private Capes $capes,
|
||||
private CsrfToken $csrfp,
|
||||
private object $authInfo,
|
||||
private ?V1User $authInfo,
|
||||
private string $baseUrl
|
||||
) {
|
||||
if(!is_dir(self::TEXTURES_PATH))
|
||||
|
@ -57,11 +58,11 @@ class SkinsRoutes implements RouteHandler, UrlSource {
|
|||
|
||||
#[HttpMiddleware('/skins')]
|
||||
public function verifyRequest($response, $request) {
|
||||
if(!$this->authInfo->success)
|
||||
if($this->authInfo === null)
|
||||
return 403;
|
||||
|
||||
try {
|
||||
$this->linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->user_id);
|
||||
$this->linkInfo = $this->accountLinks->getLink(userInfo: $this->authInfo->getId());
|
||||
} catch(RuntimeException $ex) {
|
||||
$response->redirect($this->urls->format('clients:index'));
|
||||
return true;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
namespace Mince;
|
||||
|
||||
use RuntimeException;
|
||||
use Flashii\V1\Users\V1User;
|
||||
use Index\Db\{DbConnection,DbStatementCache};
|
||||
|
||||
class Users {
|
||||
|
@ -11,16 +12,13 @@ class Users {
|
|||
$this->cache = new DbStatementCache($dbConn);
|
||||
}
|
||||
|
||||
public function syncChatUser(object $authInfo): void {
|
||||
if(!$authInfo->success)
|
||||
return;
|
||||
|
||||
$userColourFixed = ($authInfo->colour_raw & 0x40000000) ? null : $authInfo->colour_raw;
|
||||
public function syncApiUser(V1User $authInfo): void {
|
||||
$userColourFixed = $authInfo->hasColourRaw() ? $authInfo->getColourRaw() : null;
|
||||
$stmt = $this->cache->get('INSERT INTO users (user_id, user_name, user_colour) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE user_name = ?, user_colour = ?');
|
||||
$stmt->addParameter(1, $authInfo->user_id);
|
||||
$stmt->addParameter(2, $authInfo->username);
|
||||
$stmt->addParameter(1, $authInfo->getId());
|
||||
$stmt->addParameter(2, $authInfo->getName());
|
||||
$stmt->addParameter(3, $userColourFixed);
|
||||
$stmt->addParameter(4, $authInfo->username);
|
||||
$stmt->addParameter(4, $authInfo->getName());
|
||||
$stmt->addParameter(5, $userColourFixed);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue