Enhance user role management and access control in the application. Added user management link in the navigation for admins. Updated login flow to redirect to Casdoor for authentication. Improved logging for user actions and unauthorized access attempts. Adjusted role checks across various views to include '管理员' and 'admin' for access permissions.

This commit is contained in:
2025-12-10 15:53:17 +08:00
parent bb39314940
commit 0bb323bbff
24 changed files with 1285 additions and 61 deletions
+59
View File
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% block content %}
<div class="container mt-4">
<h2 class="mb-3">用户管理</h2>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="alert alert-info">
{% for message in messages %}
{{ message }}
{% endfor %}
</div>
{% endif %}
{% endwith %}
<div class="table-responsive">
<table class="table table-bordered align-middle">
<thead class="table-light">
<tr>
<th>手机号</th>
<th>姓名</th>
<th>所属支局</th>
<th>角色</th>
<th style="width: 160px;">操作</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<form method="POST" action="{{ url_for('update_user', phone=user.phone) }}">
<td>{{ user.phone }}</td>
<td>{{ user.name }}</td>
<td>
<select name="branch" class="form-select">
<option value="" {% if not user.branch %}selected{% endif %}>未设置</option>
{% for branch in branch_options %}
<option value="{{ branch }}" {% if user.branch == branch %}selected{% endif %}>{{ branch }}</option>
{% endfor %}
</select>
</td>
<td>
<select name="role" class="form-select" required>
{% for role in role_options %}
<option value="{{ role }}" {% if user.role == role %}selected{% endif %}>{{ role }}</option>
{% endfor %}
</select>
</td>
<td class="text-center">
<button type="submit" class="btn btn-primary btn-sm">保存</button>
</td>
</form>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}