refactor(pages): replace superglobals with request/session abstractions
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Http\Request;
|
||||
use MintyPHP\Http\SessionStoreInterface;
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Session;
|
||||
use MintyPHP\Support\Guard;
|
||||
|
||||
$sessionStore = app(SessionStoreInterface::class);
|
||||
$session = $sessionStore->all();
|
||||
|
||||
Guard::requireLogin();
|
||||
$userAccountService = app(\MintyPHP\Service\User\UserAccountService::class);
|
||||
$errorBag = formErrors();
|
||||
@@ -24,7 +28,7 @@ if (!Session::checkCsrfToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userId = (int) ($_SESSION['user']['id'] ?? 0);
|
||||
$userId = (int) ($session['user']['id'] ?? 0);
|
||||
if ($userId <= 0) {
|
||||
http_response_code(401);
|
||||
if (Request::wantsJson()) {
|
||||
@@ -70,7 +74,11 @@ if (!$updated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['user']['theme'] = $theme;
|
||||
$userSession = $sessionStore->get('user', []);
|
||||
if (is_array($userSession)) {
|
||||
$userSession['theme'] = $theme;
|
||||
$sessionStore->set('user', $userSession);
|
||||
}
|
||||
|
||||
if (Request::wantsJson()) {
|
||||
Router::json(['ok' => true, 'theme' => $theme]);
|
||||
|
||||
Reference in New Issue
Block a user