ユーザーは存在したらも、ログインが失敗したらエラーを発生する
諏訪子 <suwako@076.moe>、2025-12-12 12:39
コミット 6d6fa82fcf238bbe7639b2aedf3736b4328b4043
・親 83a6d5c
・ファイルを見る
2個のファイル、+10 -6
| @@ -41,9 +41,13 @@ | ||
| 41 | 41 | if (!$res->isSuccess) { |
| 42 | 42 | $error = $res->message; |
| 43 | 43 | } 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 | + } | |
| 47 | 51 | } |
| 48 | 52 | } |
| 49 | 53 | $tmpl = new Template('/'); |
変更
util.php
| @@ -113,9 +113,9 @@ | ||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | 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)); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function assert_null(mixed $assertion, Throwable|string|null $description = null): bool { |