Archived
Simplify pending setup secrets
This commit is contained in:
1 parent
5fee087b60
commit
8f07bbde84
6 files changed
+29
-23
No files matched your search
@@ -1,10 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import secrets
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
from ..security import hash_lookup_token
|
||||
from ..security import hash_lookup_token, new_bearer_secret
|
||||
|
||||
BUSY_TIMEOUT_MS = 10_000
|
||||
CACHE_SIZE_KIB = 20_000
|
||||
@@ -160,11 +159,11 @@ def initialize_schema(conn: sqlite3.Connection) -> None:
|
||||
if schema_version < 2:
|
||||
conn.execute("UPDATE accounts SET accepted_at = created_at WHERE accepted_at IS NULL")
|
||||
for row in conn.execute("SELECT hostname FROM accounts WHERE update_slug IS NULL OR update_slug = ''"):
|
||||
conn.execute("UPDATE accounts SET update_slug = ? WHERE hostname = ?", (secrets.token_urlsafe(32), row[0]))
|
||||
conn.execute("UPDATE accounts SET update_slug = ? WHERE hostname = ?", (new_bearer_secret(), row[0]))
|
||||
for row in conn.execute("SELECT hostname FROM accounts WHERE management_hash IS NULL OR management_hash = ''"):
|
||||
conn.execute(
|
||||
"UPDATE accounts SET management_hash = ? WHERE hostname = ?",
|
||||
(hash_lookup_token(secrets.token_urlsafe(32)), row[0]),
|
||||
(hash_lookup_token(new_bearer_secret()), row[0]),
|
||||
)
|
||||
_migrate_accounts_schema(conn)
|
||||
conn.execute("CREATE UNIQUE INDEX IF NOT EXISTS idx_accounts_update_slug ON accounts(update_slug)")
|
||||
|
||||
Reference in new issue
Block a user