Add admin reset-password command

Features:
- Add admin reset-password command to reset user passwords
- Support SQLite, PostgreSQL, and MySQL databases
- Use scrypt hashing compatible with CodiMD
- Update README with reset-password usage examples
This commit is contained in:
2026-04-07 12:27:23 +08:00
parent 1df784ec7c
commit 8575d7631f
4 changed files with 273 additions and 4 deletions

View File

@@ -5,13 +5,13 @@ CodiMD 的命令列工具 - 讓你可以透過終端機管理 CodiMD 協作筆
## 安裝
```bash
# 從 Git 仓库安裝
pip install git+http://192.168.42.124:31337/timmy/cli-anything-codimd.git
# 從 Git 仓库安裝(含管理員功能)
pip install -e ".[admin]" git+http://192.168.42.124:31337/timmy/cli-anything-codimd.git
# 或是複製後手動安裝
git clone http://192.168.42.124:31337/timmy/cli-anything-codimd.git
cd cli-anything-codimd/agent-harness
pip install -e .
pip install -e ".[admin]"
```
## 使用方法
@@ -75,12 +75,13 @@ cli-anything-codimd repl
| `revision get <id> <time>` | 取得特定時間的版本 |
### 管理員指令
需要直接存取 CodiMD 資料庫
需要直接存取 CodiMD 資料庫,需要安裝額外依賴:`pip install -e ".[admin]"`
| 指令 | 說明 |
|------|------|
| `admin list-users` | 列出所有使用者 |
| `admin user-notes <id>` | 列出使用者的筆記 |
| `admin reset-password` | 重設使用者密碼 |
#### 資料庫使用範例
@@ -98,6 +99,18 @@ cli-anything-codimd admin list-users --db-type mysql \
# 查看特定使用者的筆記
cli-anything-codimd admin user-notes <user-id> --db-path ./db.sqlite
# 重設使用者密碼(透過 Email
cli-anything-codimd admin reset-password --email user@example.com \
--db-path ./db.sqlite
# 重設使用者密碼(透過 User ID
cli-anything-codimd admin reset-password --user-id <user-id> \
--db-path ./db.sqlite
# 重設密碼PostgreSQL
cli-anything-codimd admin reset-password --email user@example.com \
--db-type postgresql --db-host localhost --db-name codimd --db-user postgres
```
### 設定指令