ユーザーは存在したらも、ログインが失敗したらエラーを発生する

諏訪子 <suwako@076.moe>、2025-12-12 12:39
コミット 6d6fa82fcf238bbe7639b2aedf3736b4328b4043 ・親 83a6d5c ・ファイルを見る

2個のファイル、+10 -6

@@ -41,9 +41,13 @@
4141 if (!$res->isSuccess) {
4242 $error = $res->message;
4343 } else {
44- $auth->setToken($a[0], $a[1]);
45- header('Location: /');
46- exit();
44+ $result = $auth->setToken($a[0], $a[1]);
45+ if (!$result->isSuccess) {
46+ $error = $result->message;
47+ } else {
48+ header('Location: /');
49+ exit();
50+ }
4751 }
4852 }
4953 $tmpl = new Template('/');
変更 util.php
@@ -113,9 +113,9 @@
113113 }
114114
115115 function randstr(): string {
116- srand(floor(time() / (60*60*24)));
117- $len = rand() % 20;
118- return bin2hex(random_bytes($len / 2));
116+ srand((int)floor(time() / (60*60*24)));
117+ $len = rand(1, 20);
118+ return bin2hex(random_bytes($len));
119119 }
120120
121121 function assert_null(mixed $assertion, Throwable|string|null $description = null): bool {