feat: 增加 manager 角色,admin+manager 共享管理权限(用户管理除外),所有用户可自行修改密码

- auth.py: 新增 privileged_required 装饰器 (admin+manager),admin_required 仅限用户管理
- 路由权限: fixture/logs/device_logs/test_data 的 admin 检查改为 admin+manager
- 前端: 导航栏/删除按钮/配置按钮扩展为 admin+manager 可见
- 用户管理: 角色下拉增加 manager 选项,仍仅 admin 可访问
- 新增 /change-password 路由+模板,所有登录用户可自行修改密码
- edc_server models.py: role COMMENT 更新 + ALTER TABLE 迁移
This commit is contained in:
wangfq
2026-06-11 09:11:54 +08:00
parent 50451de2df
commit 000e4f8d3a
12 changed files with 119 additions and 14 deletions

View File

@@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block title %}修改密码 - EDC 工装管理系统{% endblock %}
{% block content %}
<div style="max-width:400px;margin:40px auto;">
<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 %}
<form method="POST" style="display:flex;flex-direction:column;gap:16px;">
<div>
<label>当前密码</label>
<input type="password" name="old_password" required
style="width:100%;padding:8px;border:1px solid #ccc;border-radius:4px;">
</div>
<div>
<label>新密码至少6位</label>
<input type="password" name="new_password" required minlength="6"
style="width:100%;padding:8px;border:1px solid #ccc;border-radius:4px;">
</div>
<div>
<label>确认新密码</label>
<input type="password" name="confirm_password" required minlength="6"
style="width:100%;padding:8px;border:1px solid #ccc;border-radius:4px;">
</div>
<div style="display:flex;justify-content:space-between;">
<a href="/" style="line-height:36px;">← 返回</a>
<button type="submit" class="btn-search" style="padding:8px 24px;">确认修改</button>
</div>
</form>
</div>
{% endblock %}