mining checker
This commit is contained in:
@@ -3,40 +3,20 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 5) . '/src/App/bootstrap.php';
|
||||
require_once dirname(__DIR__, 5) . '/modules/mining-checker/bootstrap.php';
|
||||
|
||||
use App\ConfigLoader;
|
||||
use App\AccountGate;
|
||||
use App\KeycloakAuth;
|
||||
use MiningChecker\LegacyModuleStore;
|
||||
use MiningChecker\MiningCheckerUserScope;
|
||||
use Modules\MiningChecker\Legacy\LegacyModuleStore;
|
||||
use Modules\MiningChecker\Legacy\UserScope;
|
||||
use ModulesCore\ModuleHttp;
|
||||
|
||||
session_start();
|
||||
|
||||
$projectRoot = dirname(__DIR__, 5);
|
||||
$auth = new KeycloakAuth(ConfigLoader::load($projectRoot, 'keycloak'));
|
||||
$accountGate = new AccountGate(ConfigLoader::load($projectRoot, 'registration'));
|
||||
ModuleHttp::requireDesktopAccess($projectRoot, true);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if ($auth->isAuthenticated()) {
|
||||
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
|
||||
$accountCheck = $accountGate->checkUsername((string) ($currentUser['username'] ?? ''));
|
||||
|
||||
if (!($accountCheck['allowed'] ?? false)) {
|
||||
$auth->logout();
|
||||
http_response_code(403);
|
||||
echo json_encode(['error' => (string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.')], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$auth->shouldShowDesktop()) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'Nicht autorisiert.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$store = new LegacyModuleStore($projectRoot, MiningCheckerUserScope::current());
|
||||
$store = new LegacyModuleStore($projectRoot, UserScope::current());
|
||||
$method = strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
|
||||
|
||||
if ($method === 'GET') {
|
||||
|
||||
Reference in New Issue
Block a user