refactor(pages): replace superglobals with request/session abstractions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Buffer;
|
||||
use MintyPHP\Http\SessionStoreInterface;
|
||||
use MintyPHP\I18n;
|
||||
use MintyPHP\Repository\Auth\PasswordResetRepository;
|
||||
use MintyPHP\Repository\Auth\RememberTokenRepository;
|
||||
@@ -10,6 +11,9 @@ use MintyPHP\Service\CustomField\UserCustomFieldValueService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Support\Guard;
|
||||
|
||||
$sessionStore = app(SessionStoreInterface::class);
|
||||
$session = $sessionStore->all();
|
||||
|
||||
Guard::requireLogin();
|
||||
$request = requestInput();
|
||||
$userAccountService = app(\MintyPHP\Service\User\UserAccountService::class);
|
||||
@@ -31,7 +35,7 @@ $departmentService = app(\MintyPHP\Service\Org\DepartmentService::class);
|
||||
$passwordMinLength = $userPasswordPolicyService->minLength();
|
||||
$passwordHints = $userPasswordPolicyService->hints();
|
||||
|
||||
$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
|
||||
$currentUserId = (int) ($session['user']['id'] ?? 0);
|
||||
$uuid = trim((string) ($id ?? ''));
|
||||
$user = $uuid !== '' ? $userAccountService->findByUuid($uuid) : null;
|
||||
if (!$user) {
|
||||
@@ -269,10 +273,18 @@ if ($request->hasBody('email')) {
|
||||
if ($currentUserId === $userId && isset($form['theme'])) {
|
||||
$themes = appThemes();
|
||||
$themeValue = strtolower(trim((string) ($form['theme'] ?? '')));
|
||||
$_SESSION['user']['theme'] = isset($themes[$themeValue]) ? $themeValue : appDefaultTheme();
|
||||
$userSession = $sessionStore->get('user', []);
|
||||
if (is_array($userSession)) {
|
||||
$userSession['theme'] = isset($themes[$themeValue]) ? $themeValue : appDefaultTheme();
|
||||
$sessionStore->set('user', $userSession);
|
||||
}
|
||||
}
|
||||
if ($currentUserId === $userId && isset($form['locale'])) {
|
||||
$_SESSION['user']['locale'] = $form['locale'];
|
||||
$userSession = $sessionStore->get('user', []);
|
||||
if (is_array($userSession)) {
|
||||
$userSession['locale'] = $form['locale'];
|
||||
$sessionStore->set('user', $userSession);
|
||||
}
|
||||
I18n::$locale = $form['locale'];
|
||||
}
|
||||
if (!$errorBag->hasAny()) {
|
||||
|
||||
Reference in New Issue
Block a user