ごめん
諏訪子 <suwako@076.moe>、2025-12-12 01:01
コミット 667ac47af03c968f2a00498518a3763bf93c4253
・親 72f3f5d
・ファイルを見る
2個のファイル、+8 -2
| @@ -158,6 +158,10 @@ | ||
| 158 | 158 | $auth = new Auth; |
| 159 | 159 | $user = $auth->getLoggedInUser(); |
| 160 | 160 | $u = $auth->getUser($name); |
| 161 | + if (!$u) { | |
| 162 | + header('Location: /404'); | |
| 163 | + exit(); | |
| 164 | + } | |
| 161 | 165 | |
| 162 | 166 | $tmpl = new Template('/'); |
| 163 | 167 | $pagetit = 'サインイン'; |
| @@ -34,8 +34,9 @@ | ||
| 34 | 34 | return $this->pubUser; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function getUser(string $name): \stdClass { | |
| 37 | + public function getUser(string $name): \stdClass|null { | |
| 38 | 38 | $user = $this->getUserDataFromName($name); |
| 39 | + if (!$user) return null; | |
| 39 | 40 | unset($user->password); |
| 40 | 41 | unset($user->tokens); |
| 41 | 42 | $myself = $this->getUserData(); |
| @@ -306,7 +307,7 @@ | ||
| 306 | 307 | return json_decode($lines); |
| 307 | 308 | } |
| 308 | 309 | |
| 309 | - private function getUserDataFromName(string $name): \stdClass { | |
| 310 | + private function getUserDataFromName(string $name): \stdClass|null { | |
| 310 | 311 | if (!AUTH_ENABLED) return new \stdClass; |
| 311 | 312 | $file = scandir($this->dataDir); |
| 312 | 313 | $userFile = ""; |
| @@ -321,6 +322,7 @@ | ||
| 321 | 322 | } |
| 322 | 323 | } |
| 323 | 324 | } |
| 325 | + if (!$userFile) return null; | |
| 324 | 326 | $path = $this->dataDir.$userFile; |
| 325 | 327 | unset($file, $userFile); |
| 326 | 328 |