cnb.cYcEnOSHAGA commited on
Commit ·
cbeecf4
1
Parent(s): 2e79d64
refactor: 删除 Cloud Campus 子网页独立密码功能
Browse files- cloud.html: 移除登录门控,页面直接可访问提交表单
- app.py: 移除 /authserver/cloud/login 路由,简化 cloud_page
- db.py: 移除 get_cloud_password / set_cloud_password 函数
- admin.html: 移除 Cloud Campus 独立密码管理卡片
- app.py +3 -27
- db.py +2 -23
- templates/admin.html +0 -41
- templates/cloud.html +17 -86
app.py
CHANGED
|
@@ -30,7 +30,6 @@ from db import create_submission, get_submission_by_time, get_all_submissions, u
|
|
| 30 |
from db import add_chat_message, get_chat_messages, update_chat_user_name
|
| 31 |
from db import save_log_history, get_log_history
|
| 32 |
from db import get_super_password, set_super_password
|
| 33 |
-
from db import get_cloud_password, set_cloud_password
|
| 34 |
from db import get_auto_exec_config, set_auto_exec_config
|
| 35 |
|
| 36 |
# 初始化数据库
|
|
@@ -422,25 +421,8 @@ def chat_history():
|
|
| 422 |
|
| 423 |
@app.route('/authserver/cloud')
|
| 424 |
def cloud_page():
|
| 425 |
-
"""Cloud Campus 代刷服务平台
|
| 426 |
-
|
| 427 |
-
is_admin = session.get('user', {}).get('role') == '管理员'
|
| 428 |
-
cloud_ok = session.get('cloud_authenticated', False)
|
| 429 |
-
return render_template('cloud.html',
|
| 430 |
-
cloud_authenticated=is_admin or cloud_ok)
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
@app.route('/authserver/cloud/login', methods=['POST'])
|
| 434 |
-
def cloud_login():
|
| 435 |
-
"""Cloud Campus 独立登录(密码验证)"""
|
| 436 |
-
data = request.get_json(force=True, silent=True) or {}
|
| 437 |
-
password = (data.get('password') or '').strip()
|
| 438 |
-
if not password:
|
| 439 |
-
return jsonify({'success': False, 'message': '请输入访问密码'})
|
| 440 |
-
if password == get_cloud_password():
|
| 441 |
-
session['cloud_authenticated'] = True
|
| 442 |
-
return jsonify({'success': True, 'message': '验证通过'})
|
| 443 |
-
return jsonify({'success': False, 'message': '密码错误'})
|
| 444 |
|
| 445 |
|
| 446 |
@app.route('/authserver/cloud/submit', methods=['POST'])
|
|
@@ -613,7 +595,7 @@ def cloud_reject():
|
|
| 613 |
@app.route('/authserver/cloud/config', methods=['POST'])
|
| 614 |
@admin_required
|
| 615 |
def cloud_set_config():
|
| 616 |
-
"""更新自动执行默认参数 / 超级密码
|
| 617 |
data = request.get_json(force=True, silent=True) or {}
|
| 618 |
if 'super_password' in data:
|
| 619 |
new_pwd = (data.get('super_password') or '').strip()
|
|
@@ -621,12 +603,6 @@ def cloud_set_config():
|
|
| 621 |
return jsonify({'success': False, 'message': '超级密码至少6位'})
|
| 622 |
set_super_password(new_pwd)
|
| 623 |
return jsonify({'success': True, 'message': '超级密码已更新'})
|
| 624 |
-
if 'cloud_password' in data:
|
| 625 |
-
new_pwd = (data.get('cloud_password') or '').strip()
|
| 626 |
-
if len(new_pwd) < 4:
|
| 627 |
-
return jsonify({'success': False, 'message': 'Cloud Campus 密码至少4位'})
|
| 628 |
-
set_cloud_password(new_pwd)
|
| 629 |
-
return jsonify({'success': True, 'message': 'Cloud Campus 访问密码已更新'})
|
| 630 |
if 'batch' in data:
|
| 631 |
set_auto_exec_config('batch', int(data['batch']))
|
| 632 |
if 'delay' in data:
|
|
|
|
| 30 |
from db import add_chat_message, get_chat_messages, update_chat_user_name
|
| 31 |
from db import save_log_history, get_log_history
|
| 32 |
from db import get_super_password, set_super_password
|
|
|
|
| 33 |
from db import get_auto_exec_config, set_auto_exec_config
|
| 34 |
|
| 35 |
# 初始化数据库
|
|
|
|
| 421 |
|
| 422 |
@app.route('/authserver/cloud')
|
| 423 |
def cloud_page():
|
| 424 |
+
"""Cloud Campus 代刷服务平台"""
|
| 425 |
+
return render_template('cloud.html')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
|
| 428 |
@app.route('/authserver/cloud/submit', methods=['POST'])
|
|
|
|
| 595 |
@app.route('/authserver/cloud/config', methods=['POST'])
|
| 596 |
@admin_required
|
| 597 |
def cloud_set_config():
|
| 598 |
+
"""更新自动执行默认参数 / 超级密码"""
|
| 599 |
data = request.get_json(force=True, silent=True) or {}
|
| 600 |
if 'super_password' in data:
|
| 601 |
new_pwd = (data.get('super_password') or '').strip()
|
|
|
|
| 603 |
return jsonify({'success': False, 'message': '超级密码至少6位'})
|
| 604 |
set_super_password(new_pwd)
|
| 605 |
return jsonify({'success': True, 'message': '超级密码已更新'})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
if 'batch' in data:
|
| 607 |
set_auto_exec_config('batch', int(data['batch']))
|
| 608 |
if 'delay' in data:
|
db.py
CHANGED
|
@@ -83,12 +83,10 @@ def init_db():
|
|
| 83 |
);
|
| 84 |
""")
|
| 85 |
|
| 86 |
-
# 插入默认配置(含超级密码
|
| 87 |
default_super_pwd = os.environ.get('ADMIN_SECRET', 'qwertyuiop')
|
| 88 |
-
default_cloud_pwd = os.environ.get('CLOUD_PASSWORD', 'cloud123')
|
| 89 |
for k, v in [('batch', '4'), ('delay', '0.8'), ('force_all', '0'),
|
| 90 |
-
('super_password', default_super_pwd)
|
| 91 |
-
('cloud_password', default_cloud_pwd)]:
|
| 92 |
conn.execute(
|
| 93 |
"INSERT OR IGNORE INTO auto_exec_config (key, value) VALUES (?, ?)", (k, v))
|
| 94 |
|
|
@@ -491,22 +489,3 @@ def set_super_password(new_pwd: str):
|
|
| 491 |
(new_pwd,))
|
| 492 |
conn.commit()
|
| 493 |
conn.close()
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
def get_cloud_password() -> str:
|
| 497 |
-
"""获取 Cloud Campus 子网页访问密码"""
|
| 498 |
-
conn = get_db()
|
| 499 |
-
row = conn.execute(
|
| 500 |
-
"SELECT value FROM auto_exec_config WHERE key = 'cloud_password'").fetchone()
|
| 501 |
-
conn.close()
|
| 502 |
-
return row['value'] if row else os.environ.get('CLOUD_PASSWORD', 'cloud123')
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
def set_cloud_password(new_pwd: str):
|
| 506 |
-
"""修改 Cloud Campus 子网页访问密码"""
|
| 507 |
-
conn = get_db()
|
| 508 |
-
conn.execute(
|
| 509 |
-
"INSERT OR REPLACE INTO auto_exec_config (key, value) VALUES ('cloud_password', ?)",
|
| 510 |
-
(new_pwd,))
|
| 511 |
-
conn.commit()
|
| 512 |
-
conn.close()
|
|
|
|
| 83 |
);
|
| 84 |
""")
|
| 85 |
|
| 86 |
+
# 插入默认配置(含超级密码)
|
| 87 |
default_super_pwd = os.environ.get('ADMIN_SECRET', 'qwertyuiop')
|
|
|
|
| 88 |
for k, v in [('batch', '4'), ('delay', '0.8'), ('force_all', '0'),
|
| 89 |
+
('super_password', default_super_pwd)]:
|
|
|
|
| 90 |
conn.execute(
|
| 91 |
"INSERT OR IGNORE INTO auto_exec_config (key, value) VALUES (?, ?)", (k, v))
|
| 92 |
|
|
|
|
| 489 |
(new_pwd,))
|
| 490 |
conn.commit()
|
| 491 |
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/admin.html
CHANGED
|
@@ -225,20 +225,6 @@
|
|
| 225 |
|
| 226 |
<!-- Cloud Campus -->
|
| 227 |
<div id="tab-cloud" style="display:none">
|
| 228 |
-
<!-- Cloud Campus 独立密码管理 -->
|
| 229 |
-
<div class="card" style="margin-bottom:16px;padding:20px 24px">
|
| 230 |
-
<h3 style="font-size:14px;color:#1e293b;margin-bottom:12px">🔐 Cloud Campus 子网页独立密码</h3>
|
| 231 |
-
<p style="font-size:12px;color:#86909c;margin-bottom:12px">访问 <code style="background:#f1f5f9;padding:2px 6px;border-radius:4px">/authserver/cloud</code> 时需要此密码。与管理系统超级密码独立。</p>
|
| 232 |
-
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px">
|
| 233 |
-
<div class="form-item" style="flex:1;min-width:200px;margin:0">
|
| 234 |
-
<input type="password" id="cloudPwdInput" placeholder="输入新 Cloud Campus 密码(至少4位)" minlength="4">
|
| 235 |
-
</div>
|
| 236 |
-
<button class="btn-form cc-btn-run" onclick="changeCloudPwd()" style="white-space:nowrap">更新 Cloud 密码</button>
|
| 237 |
-
<span class="msg msg-ok" id="cloudPwdOk" style="margin:0">Cloud Campus 密码已更新</span>
|
| 238 |
-
<span class="msg msg-err" id="cloudPwdErr" style="margin:0"></span>
|
| 239 |
-
</div>
|
| 240 |
-
</div>
|
| 241 |
-
|
| 242 |
<div class="cc-subtabs">
|
| 243 |
<button class="cc-subtab active" onclick="showCcTab('submissions')">📋 提交记录</button>
|
| 244 |
<button class="cc-subtab" onclick="showCcTab('jobs')">⚡ 任务队列</button>
|
|
@@ -499,33 +485,6 @@
|
|
| 499 |
}
|
| 500 |
}
|
| 501 |
|
| 502 |
-
// ---- Cloud Campus 独立密码 ----
|
| 503 |
-
async function changeCloudPwd() {
|
| 504 |
-
const pwd = document.getElementById('cloudPwdInput').value.trim();
|
| 505 |
-
const ok = document.getElementById('cloudPwdOk');
|
| 506 |
-
const err = document.getElementById('cloudPwdErr');
|
| 507 |
-
ok.classList.remove('show');
|
| 508 |
-
err.classList.remove('show');
|
| 509 |
-
if (!pwd || pwd.length < 4) { err.textContent = 'Cloud Campus 密码至少4位'; err.classList.add('show'); return; }
|
| 510 |
-
try {
|
| 511 |
-
const r = await fetch('/authserver/cloud/config', {
|
| 512 |
-
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
| 513 |
-
body: JSON.stringify({ cloud_password: pwd })
|
| 514 |
-
});
|
| 515 |
-
const d = await r.json();
|
| 516 |
-
if (d.success) {
|
| 517 |
-
ok.classList.add('show');
|
| 518 |
-
document.getElementById('cloudPwdInput').value = '';
|
| 519 |
-
} else {
|
| 520 |
-
err.textContent = d.message;
|
| 521 |
-
err.classList.add('show');
|
| 522 |
-
}
|
| 523 |
-
} catch {
|
| 524 |
-
err.textContent = '网络异常';
|
| 525 |
-
err.classList.add('show');
|
| 526 |
-
}
|
| 527 |
-
}
|
| 528 |
-
|
| 529 |
// ========== Cloud Campus ==========
|
| 530 |
let eventSource = null;
|
| 531 |
let currentJobId = null;
|
|
|
|
| 225 |
|
| 226 |
<!-- Cloud Campus -->
|
| 227 |
<div id="tab-cloud" style="display:none">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
<div class="cc-subtabs">
|
| 229 |
<button class="cc-subtab active" onclick="showCcTab('submissions')">📋 提交记录</button>
|
| 230 |
<button class="cc-subtab" onclick="showCcTab('jobs')">⚡ 任务队列</button>
|
|
|
|
| 485 |
}
|
| 486 |
}
|
| 487 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
// ========== Cloud Campus ==========
|
| 489 |
let eventSource = null;
|
| 490 |
let currentJobId = null;
|
templates/cloud.html
CHANGED
|
@@ -62,15 +62,6 @@ xiao<!DOCTYPE html>
|
|
| 62 |
}
|
| 63 |
.form-item input:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,0.15)}
|
| 64 |
.form-item input::placeholder{color:rgba(255,255,255,0.2)}
|
| 65 |
-
.pwd-wrap{position:relative}
|
| 66 |
-
.pwd-wrap input{padding-right:42px}
|
| 67 |
-
.pwd-toggle{
|
| 68 |
-
position:absolute;right:4px;top:50%;transform:translateY(-50%);
|
| 69 |
-
width:34px;height:34px;display:flex;align-items:center;justify-content:center;
|
| 70 |
-
background:none;border:none;cursor:pointer;color:rgba(255,255,255,0.35);
|
| 71 |
-
font-size:18px;border-radius:8px;transition:color .2s;
|
| 72 |
-
}
|
| 73 |
-
.pwd-toggle:hover{color:rgba(255,255,255,0.7)}
|
| 74 |
|
| 75 |
.btn{
|
| 76 |
width:100%;padding:13px;font-size:16px;font-weight:600;
|
|
@@ -104,89 +95,29 @@ xiao<!DOCTYPE html>
|
|
| 104 |
<p>代刷服务平台</p>
|
| 105 |
</div>
|
| 106 |
|
| 107 |
-
<
|
| 108 |
-
<div class="
|
| 109 |
-
<p style="text-align:center;font-size:13px;color:rgba(255,255,255,0.5);margin-bottom:16px">
|
| 110 |
-
请输入 Cloud Campus 访问密码
|
| 111 |
-
</p>
|
| 112 |
-
<div class="form-item pwd-wrap">
|
| 113 |
-
<input type="password" id="cloudPwd" placeholder="输入独立访问密码" onkeydown="if(event.key==='Enter')doCloudLogin()">
|
| 114 |
-
<button type="button" class="pwd-toggle" id="cloudPwdToggle" onclick="togglePwd('cloudPwd','cloudPwdToggle')" title="显示密码">👁</button>
|
| 115 |
-
</div>
|
| 116 |
-
<div class="msg msg-err" id="loginErr"></div>
|
| 117 |
-
<button class="btn" id="loginBtn" onclick="doCloudLogin()">验 证</button>
|
| 118 |
-
</div>
|
| 119 |
-
|
| 120 |
-
<!-- 提交表单 -->
|
| 121 |
-
<div id="submitGate" {% if not cloud_authenticated %}style="display:none"{% endif %}>
|
| 122 |
-
<div class="msg msg-err" id="msgErr"></div>
|
| 123 |
-
<div class="msg msg-ok" id="msgOk">✅ 提交成功,请等待管理员审核</div>
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
</div>
|
| 130 |
-
<div class="form-item">
|
| 131 |
-
<label>Pass(密码)</label>
|
| 132 |
-
<input type="password" id="password" placeholder="输入密码">
|
| 133 |
-
</div>
|
| 134 |
-
<div class="form-item">
|
| 135 |
-
<label>H5P / Course ID(课程代码)</label>
|
| 136 |
-
<input type="text" id="course" placeholder="输入课程代码,如 12345">
|
| 137 |
-
</div>
|
| 138 |
-
<button class="btn" id="submitBtn" onclick="doSubmit()">提 交</button>
|
| 139 |
</div>
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
</div>
|
|
|
|
|
|
|
| 143 |
</div>
|
| 144 |
|
| 145 |
<script>
|
| 146 |
-
function togglePwd(inputId, btnId) {
|
| 147 |
-
const inp = document.getElementById(inputId);
|
| 148 |
-
const btn = document.getElementById(btnId);
|
| 149 |
-
if (inp.type === 'password') {
|
| 150 |
-
inp.type = 'text';
|
| 151 |
-
btn.textContent = '🙈';
|
| 152 |
-
btn.title = '隐藏密码';
|
| 153 |
-
} else {
|
| 154 |
-
inp.type = 'password';
|
| 155 |
-
btn.textContent = '👁';
|
| 156 |
-
btn.title = '显示密码';
|
| 157 |
-
}
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
async function doCloudLogin() {
|
| 161 |
-
const password = document.getElementById('cloudPwd').value.trim();
|
| 162 |
-
const err = document.getElementById('loginErr');
|
| 163 |
-
err.classList.remove('show');
|
| 164 |
-
|
| 165 |
-
if (!password) { err.textContent = '请输入访问密码'; err.classList.add('show'); return; }
|
| 166 |
-
|
| 167 |
-
const btn = document.getElementById('loginBtn');
|
| 168 |
-
btn.disabled = true; btn.textContent = '验证中...';
|
| 169 |
-
|
| 170 |
-
try {
|
| 171 |
-
const r = await fetch('/authserver/cloud/login', {
|
| 172 |
-
method: 'POST',
|
| 173 |
-
headers: { 'Content-Type': 'application/json' },
|
| 174 |
-
body: JSON.stringify({ password }),
|
| 175 |
-
});
|
| 176 |
-
const d = await r.json();
|
| 177 |
-
if (d.success) {
|
| 178 |
-
document.getElementById('loginGate').style.display = 'none';
|
| 179 |
-
document.getElementById('submitGate').style.display = '';
|
| 180 |
-
} else {
|
| 181 |
-
err.textContent = d.message; err.classList.add('show');
|
| 182 |
-
}
|
| 183 |
-
} catch {
|
| 184 |
-
err.textContent = '网络异常'; err.classList.add('show');
|
| 185 |
-
} finally {
|
| 186 |
-
btn.disabled = false; btn.textContent = '验 证';
|
| 187 |
-
}
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
async function doSubmit() {
|
| 191 |
const account = document.getElementById('account').value.trim();
|
| 192 |
const password = document.getElementById('password').value.trim();
|
|
|
|
| 62 |
}
|
| 63 |
.form-item input:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,0.15)}
|
| 64 |
.form-item input::placeholder{color:rgba(255,255,255,0.2)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
.btn{
|
| 67 |
width:100%;padding:13px;font-size:16px;font-weight:600;
|
|
|
|
| 95 |
<p>代刷服务平台</p>
|
| 96 |
</div>
|
| 97 |
|
| 98 |
+
<div class="msg msg-err" id="msgErr"></div>
|
| 99 |
+
<div class="msg msg-ok" id="msgOk">✅ 提交成功,请等待管理员审核</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
<div class="card">
|
| 102 |
+
<div class="form-item">
|
| 103 |
+
<label>User(账户)</label>
|
| 104 |
+
<input type="text" id="account" placeholder="输入账号 / 学号">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
</div>
|
| 106 |
+
<div class="form-item">
|
| 107 |
+
<label>Pass(密码)</label>
|
| 108 |
+
<input type="password" id="password" placeholder="输入密码">
|
| 109 |
+
</div>
|
| 110 |
+
<div class="form-item">
|
| 111 |
+
<label>H5P / Course ID(课程代码)</label>
|
| 112 |
+
<input type="text" id="course" placeholder="输入课程代码,如 12345">
|
| 113 |
+
</div>
|
| 114 |
+
<button class="btn" id="submitBtn" onclick="doSubmit()">提 交</button>
|
| 115 |
</div>
|
| 116 |
+
|
| 117 |
+
<div class="footer">Cloud Campus © 2026 · 代刷服务平台</div>
|
| 118 |
</div>
|
| 119 |
|
| 120 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
async function doSubmit() {
|
| 122 |
const account = document.getElementById('account').value.trim();
|
| 123 |
const password = document.getElementById('password').value.trim();
|