ごめん

諏訪子 <suwako@076.moe>、2025-12-12 01:01
コミット 667ac47af03c968f2a00498518a3763bf93c4253 ・親 72f3f5d ・ファイルを見る

2個のファイル、+8 -2

@@ -158,6 +158,10 @@
158158 $auth = new Auth;
159159 $user = $auth->getLoggedInUser();
160160 $u = $auth->getUser($name);
161+ if (!$u) {
162+ header('Location: /404');
163+ exit();
164+ }
161165
162166 $tmpl = new Template('/');
163167 $pagetit = 'サインイン';
@@ -34,8 +34,9 @@
3434 return $this->pubUser;
3535 }
3636
37- public function getUser(string $name): \stdClass {
37+ public function getUser(string $name): \stdClass|null {
3838 $user = $this->getUserDataFromName($name);
39+ if (!$user) return null;
3940 unset($user->password);
4041 unset($user->tokens);
4142 $myself = $this->getUserData();
@@ -306,7 +307,7 @@
306307 return json_decode($lines);
307308 }
308309
309- private function getUserDataFromName(string $name): \stdClass {
310+ private function getUserDataFromName(string $name): \stdClass|null {
310311 if (!AUTH_ENABLED) return new \stdClass;
311312 $file = scandir($this->dataDir);
312313 $userFile = "";
@@ -321,6 +322,7 @@
321322 }
322323 }
323324 }
325+ if (!$userFile) return null;
324326 $path = $this->dataDir.$userFile;
325327 unset($file, $userFile);
326328