Warren 3221b10918 feat: Add user authentication for File Tree with id/password login
Major features:
1. File Tree authentication system:
   - User ID + Password login modal
   - Each user_id accesses separate database (data/users/<user_id>.sqlite)
   - Reuses existing auth system (/api/v2/auth/login)

2. TreeLoginModal UI:
   - User ID input field
   - Password input with eye icon toggle (👁 ↔ 🙈)
   - Enter key submission support
   - Error messages display
   - Cross-browser compatible

3. Token-based authentication:
   - localStorage: tree_token + tree_user
   - Bearer Authorization header for all tree API calls
   - Token verification before tree access
   - Auto-clear invalid tokens

4. Modified functions:
   - toggleTree(): Check token validity before opening
   - loadTree(): Add Authorization header
   - applyIcon(): Add Authorization header
   - organizeTree(): Add Authorization header
   - New: showTreeLoginModal(), submitTreeLogin(), toggleTreePassword()

5. Security improvements:
   - Restored verify_auth() check in get_tree() handler
   - All tree API endpoints require authentication
   - User-specific database access control

Architecture:
- Independent from admin authentication system
- Uses same backend auth (PostgreSQL sync)
- Separate localStorage keys (tree_token vs admin_token)

User workflow:
1. Click 🗂File Tree → Login modal appears
2. Enter user_id (e.g., demo) + password (e.g., demo123)
3. Login success → Tree loads with user-specific data
4. Each user sees only their own files

Files changed:
- src/server.rs: Restored auth check in get_tree()
- src/page.html: +130 lines (login modal + auth logic)

Test credentials:
- demo / demo123 (50 nodes)
- warren / demo123
- momentry / demo123

Status: File Tree authentication fully functional
2026-05-16 22:30:07 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00
2026-05-16 15:37:37 +08:00

MarkBase

Momentry Display Engine - Markdown渲染與檔案樹管理系統

功能特色

  • Markdown渲染支援表格、footnote、tasklist -檔案樹管理SQLite持久化
  • REST API18+路由)
  • macOS音訊控制音訊裝置切換、音量控制 -多種顯示模式tree, list, grid_sm, grid_lg

##安裝

###必要條件

  • Rust 1.92+
  • macOS音訊功能需 macOS
  • SwitchAudioSource音訊裝置切換
#安裝 Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

#安裝 SwitchAudioSourcemacOS
brew install switchaudio-source

###建構

cargo build

##使用

###啟動伺服器

cargo run -- display                #預設 port 11438
cargo run -- display -p8080         #自訂 port
cargo run -- display README.md      #顯示指定檔案

###渲染 Markdown

cargo run -- render README.md       #輸出到 stdout
cargo run -- render README.md -o output.html

##測試

cargo test                          #執行所有測試
cargo test test_insert              #執行特定測試

File Tree功能

REST API

路由 方法 功能
/api/v2/tree/:user_id GET 取得檔案樹
/api/v2/tree/:user_id/node POST 建立節點
/api/v2/tree/:user_id/node/:node_id PUT/DELETE 更新/刪除節點
/api/v2/tree/:user_id/node/:node_id/move PUT 移動節點
/api/v2/tree/:user_id/node/:node_id/alias PATCH 更新別名

###顯示模式

  • tree - 樹狀顯示
  • list - 列表顯示
  • grid_sm - 小格狀顯示
  • grid_lg - 大格狀顯示

###範例

curl http://localhost:11438/api/v2/tree/demo?mode=tree
curl http://localhost:11438/api/v2/tree/demo?mode=list

Demo資料

  • data/users/demo.sqlite - 50節點範例資料
  • data/cache/ -範例檔案

##開發

AGENTS.md詳細開發指南。

CI/CD

使用 Gitea Actionshttps://gitea.momentry.ddns.net

License

MIT

Description
No description provided
Readme 4 MiB
Languages
Rust 74.3%
HTML 14.4%
Shell 11.3%