ai_co_discuss 0.2.95 → 0.2.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/admin.py +6 -1
- package/backend/runtime.py +426 -416
- package/backend/schema.sql +6 -0
- package/backend/server.py +2372 -2359
- package/docs/deployment.md +3 -3
- package/docs/en/deployment.md +3 -3
- package/package.json +3 -2
- package/runner/admin_account.mjs +66 -0
- package/runner/codiscuss.mjs +3 -0
- package/runner/discussion_launch.mjs +3 -0
- package/runner/free_runner.mjs +4 -3
- package/web/app.js +41 -29
- package/web/markdown.js +5 -5
- package/web/modern.css +1 -1
- package/web/modern.js +2185 -2043
package/backend/admin.py
CHANGED
|
@@ -126,10 +126,15 @@ def register_admin(connection, payload, setup_key, now):
|
|
|
126
126
|
username = valid_username(payload.get("username"))
|
|
127
127
|
password = valid_password(payload.get("password"))
|
|
128
128
|
supplied = payload.get("setup_key")
|
|
129
|
-
|
|
129
|
+
setup = connection.execute("SELECT token_hash FROM admin_setup WHERE id=1").fetchone()
|
|
130
|
+
# Either the install token or the one-time token written by `codiscuss admin token` registers.
|
|
131
|
+
if not isinstance(supplied, str) or not (
|
|
132
|
+
same_secret(supplied.strip(), setup_key)
|
|
133
|
+
or setup and hmac.compare_digest(hashlib.sha256(supplied.strip().encode()).hexdigest(), setup["token_hash"])):
|
|
130
134
|
raise AdminError("安装令牌不正确", 403)
|
|
131
135
|
connection.execute("INSERT INTO site_admin (id,username,password_hash,created_at) VALUES (1,?,?,?)",
|
|
132
136
|
(username, hash_password(password), now))
|
|
137
|
+
connection.execute("DELETE FROM admin_setup")
|
|
133
138
|
return {"token": open_session(connection, now), "profile": {"username": username, "avatar": ""}}
|
|
134
139
|
|
|
135
140
|
|