Check editor accounts.

A new editor needs a username and a password of at least 12 characters. A persistent login needs an unexpired key and an existing account. Removing an account revokes its persistent logins, and its sessions end.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent 5d657d7e45
commit 3df88e0b4c
10 changed files with 217 additions and 16 deletions
+10 -1
View File
@@ -124,8 +124,17 @@ abstract class PageTestCase extends \PHPUnit\Framework\TestCase {
return $id;
}
// An editor's session, with a CSRF token; returns the token
/*
* An editor's session, with a CSRF token; returns the token. The pages
* log out an editor without an account, so this adds the account to the
* editors table if it is missing.
*/
protected function loginAs(string $username = 'ed', array $data = array()): string {
$saved = unserialize(file_get_contents(self::$state . '/tables.ser'));
if (!in_array($username, array_column($saved['tables']['editors'], 'username'), TRUE)) {
$saved['tables']['editors'][] = array('username' => $username, 'password' => '', 'email' => '');
file_put_contents(self::$state . '/tables.ser', serialize($saved));
}
$token = str_repeat('c0ffee', 10) . 'c0de';
$this->startSession($data + array('editor' => $username, 'csrf_token' => $token));
return $token;