Upload 3 files
Browse files- README.md +15 -22
- config.php +6 -24
- user-manager.php +0 -18
README.md
CHANGED
|
@@ -18,9 +18,9 @@ license: apache-2.0
|
|
| 18 |
- 👥 GitHub-based user management with real-time sync
|
| 19 |
- 🔄 Undo/Redo functionality
|
| 20 |
|
| 21 |
-
## 🔄
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
### 主要特性
|
| 26 |
- ✅ **实时同步:** 每次登录都从GitHub仓库加载最新用户数据
|
|
@@ -68,13 +68,13 @@ EDGEONE_KV_ZONE_ID=your_zone_id
|
|
| 68 |
|
| 69 |
## User Management Modes
|
| 70 |
|
| 71 |
-
### 1. GitHub User Management (
|
| 72 |
-
-
|
| 73 |
-
-
|
| 74 |
- 多实例间自动同步
|
| 75 |
-
- 访问 `login.html`
|
| 76 |
|
| 77 |
-
### 2. Environment Variable Mode (
|
| 78 |
- 通过环境变量预配置用户
|
| 79 |
- 使用Basic Authentication
|
| 80 |
- 适合简单部署场景
|
|
@@ -82,18 +82,12 @@ EDGEONE_KV_ZONE_ID=your_zone_id
|
|
| 82 |
## Usage
|
| 83 |
|
| 84 |
1. Access the Space URL
|
| 85 |
-
2.
|
| 86 |
-
- **GitHub Mode:** Visit `login.html` to
|
| 87 |
- **Env Mode:** Use configured username/password
|
| 88 |
3. Build your website visually
|
| 89 |
4. Pages are saved to external storage automatically
|
| 90 |
|
| 91 |
-
## Testing
|
| 92 |
-
|
| 93 |
-
- Visit `github-user-test.html` to test GitHub user management features
|
| 94 |
-
- Visit `config.php` to check system configuration and status
|
| 95 |
-
- Visit `github-advanced-test.php` for advanced diagnostics
|
| 96 |
-
|
| 97 |
## File Structure
|
| 98 |
|
| 99 |
```
|
|
@@ -109,18 +103,17 @@ users/
|
|
| 109 |
└── about.html
|
| 110 |
```
|
| 111 |
|
| 112 |
-
##
|
| 113 |
|
| 114 |
-
|
| 115 |
-
1.
|
| 116 |
-
2.
|
| 117 |
-
3.
|
| 118 |
-
4. Contact administrator for data migration assistance
|
| 119 |
|
| 120 |
## Development
|
| 121 |
|
| 122 |
The system uses a hybrid approach:
|
| 123 |
-
- **Priority 1:** GitHub user management for
|
| 124 |
- **Fallback:** Environment variable authentication for compatibility
|
| 125 |
- **Storage:** All user files stored with user isolation
|
| 126 |
|
|
|
|
| 18 |
- 👥 GitHub-based user management with real-time sync
|
| 19 |
- 🔄 Undo/Redo functionality
|
| 20 |
|
| 21 |
+
## 🔄 GitHub User Management System
|
| 22 |
|
| 23 |
+
**系统使用基于GitHub的用户管理,确保用户数据在多个实例间实时同步。**
|
| 24 |
|
| 25 |
### 主要特性
|
| 26 |
- ✅ **实时同步:** 每次登录都从GitHub仓库加载最新用户数据
|
|
|
|
| 68 |
|
| 69 |
## User Management Modes
|
| 70 |
|
| 71 |
+
### 1. GitHub User Management (默认)
|
| 72 |
+
- 用户通过GitHub仓库中的用户数据登录
|
| 73 |
+
- 支持密码修改功能
|
| 74 |
- 多实例间自动同步
|
| 75 |
+
- 访问 `login.html` 进行登录
|
| 76 |
|
| 77 |
+
### 2. Environment Variable Mode (备用)
|
| 78 |
- 通过环境变量预配置用户
|
| 79 |
- 使用Basic Authentication
|
| 80 |
- 适合简单部署场景
|
|
|
|
| 82 |
## Usage
|
| 83 |
|
| 84 |
1. Access the Space URL
|
| 85 |
+
2. Login with existing account:
|
| 86 |
+
- **GitHub Mode:** Visit `login.html` to login
|
| 87 |
- **Env Mode:** Use configured username/password
|
| 88 |
3. Build your website visually
|
| 89 |
4. Pages are saved to external storage automatically
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
## File Structure
|
| 92 |
|
| 93 |
```
|
|
|
|
| 103 |
└── about.html
|
| 104 |
```
|
| 105 |
|
| 106 |
+
## User Account Management
|
| 107 |
|
| 108 |
+
User accounts are managed through the GitHub repository. To add new users:
|
| 109 |
+
1. Manually add user data to `system/users.json` in the GitHub repository
|
| 110 |
+
2. Use proper password hashing for security
|
| 111 |
+
3. System will automatically load the updated user data on next login
|
|
|
|
| 112 |
|
| 113 |
## Development
|
| 114 |
|
| 115 |
The system uses a hybrid approach:
|
| 116 |
+
- **Priority 1:** GitHub user management for data persistence
|
| 117 |
- **Fallback:** Environment variable authentication for compatibility
|
| 118 |
- **Storage:** All user files stored with user isolation
|
| 119 |
|
config.php
CHANGED
|
@@ -54,29 +54,16 @@ if (!$authenticated) {
|
|
| 54 |
<div class="config-section">
|
| 55 |
<h2>👥 用户管理系统</h2>
|
| 56 |
<?php if ($useGitHubAuth): ?>
|
| 57 |
-
<div class="status-item status-ok">✅ 使用 GitHub
|
| 58 |
<div class="status-item status-ok">👤 当前用户: <?= htmlspecialchars($githubUserManager->getCurrentUser()) ?></div>
|
| 59 |
|
| 60 |
-
<?php
|
| 61 |
-
// Test GitHub user data loading
|
| 62 |
-
try {
|
| 63 |
-
$userList = $githubUserManager->getUserList();
|
| 64 |
-
echo '<div class="status-item status-ok">📊 GitHub 用户数据: ' . count($userList) . ' 个用户</div>';
|
| 65 |
-
foreach ($userList as $user) {
|
| 66 |
-
echo '<div class="status-item status-ok"> └ ' . htmlspecialchars($user['username']) . ' (注册: ' . $user['created'] . ')</div>';
|
| 67 |
-
}
|
| 68 |
-
} catch (Exception $e) {
|
| 69 |
-
echo '<div class="status-item status-error">❌ GitHub 用户数据加载失败: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
| 70 |
-
}
|
| 71 |
-
?>
|
| 72 |
-
|
| 73 |
<div class="mt-3">
|
| 74 |
-
<h4>💡 GitHub
|
| 75 |
<ul>
|
| 76 |
<li>✅ 用户数据存储在 GitHub 仓库中,永不丢失</li>
|
| 77 |
<li>✅ 多实例间自动同步用户数据</li>
|
| 78 |
<li>✅ 每次登录都从 GitHub 加载最新数据</li>
|
| 79 |
-
<li>✅
|
| 80 |
</ul>
|
| 81 |
</div>
|
| 82 |
<?php else: ?>
|
|
@@ -176,19 +163,14 @@ if (!$authenticated) {
|
|
| 176 |
<div class="config-section">
|
| 177 |
<h2>🚀 快速操作</h2>
|
| 178 |
<div class="row">
|
| 179 |
-
<div class="col-md-
|
| 180 |
<a href="editor.html" class="btn btn-primary btn-lg w-100">
|
| 181 |
📝 启动编辑器
|
| 182 |
</a>
|
| 183 |
</div>
|
| 184 |
-
<div class="col-md-
|
| 185 |
<a href="login.html" class="btn btn-success btn-lg w-100">
|
| 186 |
-
🔐
|
| 187 |
-
</a>
|
| 188 |
-
</div>
|
| 189 |
-
<div class="col-md-4">
|
| 190 |
-
<a href="github-advanced-test.php" class="btn btn-warning btn-lg w-100">
|
| 191 |
-
🧪 高级诊断
|
| 192 |
</a>
|
| 193 |
</div>
|
| 194 |
</div>
|
|
|
|
| 54 |
<div class="config-section">
|
| 55 |
<h2>👥 用户管理系统</h2>
|
| 56 |
<?php if ($useGitHubAuth): ?>
|
| 57 |
+
<div class="status-item status-ok">✅ 使用 GitHub 用户管理</div>
|
| 58 |
<div class="status-item status-ok">👤 当前用户: <?= htmlspecialchars($githubUserManager->getCurrentUser()) ?></div>
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
<div class="mt-3">
|
| 61 |
+
<h4>💡 GitHub 用户管理特性</h4>
|
| 62 |
<ul>
|
| 63 |
<li>✅ 用户数据存储在 GitHub 仓库中,永不丢失</li>
|
| 64 |
<li>✅ 多实例间自动同步用户数据</li>
|
| 65 |
<li>✅ 每次登录都从 GitHub 加载最新数据</li>
|
| 66 |
+
<li>✅ 支持登录和密码修改功能</li>
|
| 67 |
</ul>
|
| 68 |
</div>
|
| 69 |
<?php else: ?>
|
|
|
|
| 163 |
<div class="config-section">
|
| 164 |
<h2>🚀 快速操作</h2>
|
| 165 |
<div class="row">
|
| 166 |
+
<div class="col-md-6">
|
| 167 |
<a href="editor.html" class="btn btn-primary btn-lg w-100">
|
| 168 |
📝 启动编辑器
|
| 169 |
</a>
|
| 170 |
</div>
|
| 171 |
+
<div class="col-md-6">
|
| 172 |
<a href="login.html" class="btn btn-success btn-lg w-100">
|
| 173 |
+
🔐 用户登录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
</a>
|
| 175 |
</div>
|
| 176 |
</div>
|
user-manager.php
CHANGED
|
@@ -11,13 +11,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
| 11 |
$action = $_POST['action'] ?? '';
|
| 12 |
|
| 13 |
switch ($action) {
|
| 14 |
-
case 'register':
|
| 15 |
-
$username = $_POST['username'] ?? '';
|
| 16 |
-
$password = $_POST['password'] ?? '';
|
| 17 |
-
$email = $_POST['email'] ?? '';
|
| 18 |
-
echo json_encode($userManager->registerUser($username, $password, $email));
|
| 19 |
-
break;
|
| 20 |
-
|
| 21 |
case 'login':
|
| 22 |
$username = $_POST['username'] ?? '';
|
| 23 |
$password = $_POST['password'] ?? '';
|
|
@@ -58,17 +51,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
| 58 |
echo json_encode($userManager->changePassword($username, $oldPassword, $newPassword));
|
| 59 |
break;
|
| 60 |
|
| 61 |
-
case 'get_user_list':
|
| 62 |
-
if (!$userManager->isLoggedIn()) {
|
| 63 |
-
echo json_encode(['success' => false, 'message' => 'Not logged in']);
|
| 64 |
-
break;
|
| 65 |
-
}
|
| 66 |
-
echo json_encode([
|
| 67 |
-
'success' => true,
|
| 68 |
-
'users' => $userManager->getUserList()
|
| 69 |
-
]);
|
| 70 |
-
break;
|
| 71 |
-
|
| 72 |
default:
|
| 73 |
echo json_encode(['success' => false, 'message' => 'Invalid action']);
|
| 74 |
}
|
|
|
|
| 11 |
$action = $_POST['action'] ?? '';
|
| 12 |
|
| 13 |
switch ($action) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
case 'login':
|
| 15 |
$username = $_POST['username'] ?? '';
|
| 16 |
$password = $_POST['password'] ?? '';
|
|
|
|
| 51 |
echo json_encode($userManager->changePassword($username, $oldPassword, $newPassword));
|
| 52 |
break;
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
default:
|
| 55 |
echo json_encode(['success' => false, 'message' => 'Invalid action']);
|
| 56 |
}
|