ごめん

This commit is contained in:
2025-12-12 01:01:36 +09:00
parent 72f3f5d39b
commit 667ac47af0
2 changed files with 8 additions and 2 deletions

View File

@@ -158,6 +158,10 @@ class User {
$auth = new Auth; $auth = new Auth;
$user = $auth->getLoggedInUser(); $user = $auth->getLoggedInUser();
$u = $auth->getUser($name); $u = $auth->getUser($name);
if (!$u) {
header('Location: /404');
exit();
}
$tmpl = new Template('/'); $tmpl = new Template('/');
$pagetit = 'サインイン'; $pagetit = 'サインイン';

View File

@@ -34,8 +34,9 @@ class Auth {
return $this->pubUser; return $this->pubUser;
} }
public function getUser(string $name): \stdClass { public function getUser(string $name): \stdClass|null {
$user = $this->getUserDataFromName($name); $user = $this->getUserDataFromName($name);
if (!$user) return null;
unset($user->password); unset($user->password);
unset($user->tokens); unset($user->tokens);
$myself = $this->getUserData(); $myself = $this->getUserData();
@@ -306,7 +307,7 @@ class Auth {
return json_decode($lines); return json_decode($lines);
} }
private function getUserDataFromName(string $name): \stdClass { private function getUserDataFromName(string $name): \stdClass|null {
if (!AUTH_ENABLED) return new \stdClass; if (!AUTH_ENABLED) return new \stdClass;
$file = scandir($this->dataDir); $file = scandir($this->dataDir);
$userFile = ""; $userFile = "";
@@ -321,6 +322,7 @@ class Auth {
} }
} }
} }
if (!$userFile) return null;
$path = $this->dataDir.$userFile; $path = $this->dataDir.$userFile;
unset($file, $userFile); unset($file, $userFile);