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);