From 667ac47af03c968f2a00498518a3763bf93c4253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Fri, 12 Dec 2025 01:01:36 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=94=E3=82=81=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Site/Controller/User.php | 4 ++++ src/Site/Lib/Auth.php | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Site/Controller/User.php b/src/Site/Controller/User.php index 6e6246d..3b4c645 100644 --- a/src/Site/Controller/User.php +++ b/src/Site/Controller/User.php @@ -158,6 +158,10 @@ class User { $auth = new Auth; $user = $auth->getLoggedInUser(); $u = $auth->getUser($name); + if (!$u) { + header('Location: /404'); + exit(); + } $tmpl = new Template('/'); $pagetit = 'サインイン'; diff --git a/src/Site/Lib/Auth.php b/src/Site/Lib/Auth.php index 04ab889..61ee4f1 100644 --- a/src/Site/Lib/Auth.php +++ b/src/Site/Lib/Auth.php @@ -34,8 +34,9 @@ class Auth { return $this->pubUser; } - public function getUser(string $name): \stdClass { + public function getUser(string $name): \stdClass|null { $user = $this->getUserDataFromName($name); + if (!$user) return null; unset($user->password); unset($user->tokens); $myself = $this->getUserData(); @@ -306,7 +307,7 @@ class Auth { return json_decode($lines); } - private function getUserDataFromName(string $name): \stdClass { + private function getUserDataFromName(string $name): \stdClass|null { if (!AUTH_ENABLED) return new \stdClass; $file = scandir($this->dataDir); $userFile = ""; @@ -321,6 +322,7 @@ class Auth { } } } + if (!$userFile) return null; $path = $this->dataDir.$userFile; unset($file, $userFile);