fix: analyst 访问受限页面时自动跳转到测试数据页,并显示提示

This commit is contained in:
wangfq
2026-06-11 17:32:44 +08:00
parent 17e1d232e8
commit aa2815b5cc
2 changed files with 10 additions and 1 deletions

View File

@@ -57,7 +57,8 @@ def init_auth(app):
if current_user.is_authenticated and current_user.role == "analyst": if current_user.is_authenticated and current_user.role == "analyst":
ep = request.endpoint or "" ep = request.endpoint or ""
if ep not in ANALYST_ALLOWED and not ep.startswith("static"): if ep not in ANALYST_ALLOWED and not ep.startswith("static"):
return "权限不足:当前角色为 analyst仅可访问测试数据", 403 flash("当前角色为 analyst仅可访问测试数据")
return redirect(url_for("test_data.test_data_page"))
# ─── 装饰器 ──────────────────────────────────────────────────────── # ─── 装饰器 ────────────────────────────────────────────────────────

View File

@@ -4,6 +4,14 @@
{% block content %} {% block content %}
<h2>测试信息</h2> <h2>测试信息</h2>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div style="background:#fef3e2;color:#b45309;padding:10px;border-radius:6px;margin-bottom:16px;">
{% for msg in messages %}{{ msg }}{% endfor %}
</div>
{% endif %}
{% endwith %}
<div class="view-tabs"> <div class="view-tabs">
<button id="tab-all" class="tab-btn active" onclick="switchView('all')">全部数据</button> <button id="tab-all" class="tab-btn active" onclick="switchView('all')">全部数据</button>
<button id="tab-b2" class="tab-btn" onclick="switchView('b2')">灵敏度测试 (0xB2)</button> <button id="tab-b2" class="tab-btn" onclick="switchView('b2')">灵敏度测试 (0xB2)</button>