feat: 添加用户登录认证功能,确保系统安全性,并提供修改密码和退出登录选项
This commit is contained in:
11
templates/_account_menu.html
Normal file
11
templates/_account_menu.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<details class="account-menu">
|
||||
<summary class="btn btn-light">账号:{{ auth_username or '未登录' }}</summary>
|
||||
<div class="account-menu-list" role="menu">
|
||||
<p class="account-menu-meta">登录时间:{{ auth_login_at }}</p>
|
||||
<p class="account-menu-meta">在线时长:{{ auth_online_for }}</p>
|
||||
<p class="account-menu-meta">最后活动:{{ auth_last_active_at }}</p>
|
||||
<p class="account-menu-meta">空闲时长:{{ auth_idle_for }}</p>
|
||||
<a class="account-menu-item" href="{{ url_for('change_password_page') }}" role="menuitem">修改密码</a>
|
||||
<a class="account-menu-item" href="{{ url_for('logout_page') }}" role="menuitem">退出登录</a>
|
||||
</div>
|
||||
</details>
|
||||
@@ -14,6 +14,7 @@
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('types_page') }}">返回仓库概览</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<a class="btn btn-light" href="{{ url_for('search_page') }}">快速搜索</a>
|
||||
<a class="btn btn-light" href="{{ url_for('stats_page') }}">统计页</a>
|
||||
<a class="btn btn-light" href="{{ url_for('export_box_labels_csv', box_id=box.id) }}">导出打标CSV</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
50
templates/change_password.html
Normal file
50
templates/change_password.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>修改密码</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header class="hero slim">
|
||||
<div>
|
||||
<h1>修改密码</h1>
|
||||
<p>当前用户:{{ auth_username }}</p>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('types_page') }}">返回仓库概览</a>
|
||||
<a class="btn btn-light" href="{{ url_for('logout_page') }}">退出登录</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="panel" style="max-width: 560px; margin: 0 auto;">
|
||||
{% if error %}
|
||||
<p class="alert">{{ error }}</p>
|
||||
{% endif %}
|
||||
{% if notice %}
|
||||
<p class="notice">{{ notice }}</p>
|
||||
{% endif %}
|
||||
|
||||
<form class="form-grid" method="post" action="{{ url_for('change_password_page') }}">
|
||||
<label>
|
||||
当前密码
|
||||
<input type="password" name="current_password" required autocomplete="current-password" placeholder="请输入当前密码">
|
||||
</label>
|
||||
<label>
|
||||
新密码(至少8位)
|
||||
<input type="password" name="new_password" required minlength="8" autocomplete="new-password" placeholder="请输入新密码">
|
||||
</label>
|
||||
<label>
|
||||
确认新密码
|
||||
<input type="password" name="confirm_password" required minlength="8" autocomplete="new-password" placeholder="请再次输入新密码">
|
||||
</label>
|
||||
<div class="actions full">
|
||||
<button class="btn" type="submit">保存新密码</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,6 +16,7 @@
|
||||
<a class="btn btn-light" href="{{ url_for('search_page', q=search_query) if search_query else url_for('search_page') }}">返回快速搜索</a>
|
||||
<a class="btn btn-light" href="{{ url_for('stats_page') }}">统计页</a>
|
||||
<a class="btn btn-light" href="{{ url_for('view_box', box_id=box.id) }}">返回宫格</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<a class="btn btn-light" href="{{ url_for('search_page') }}">快速搜索</a>
|
||||
<a class="btn btn-light" href="#quick-add">新增库存</a>
|
||||
<a class="btn btn-light" href="{{ url_for('stats_page') }}">统计页</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
42
templates/login.html
Normal file
42
templates/login.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>系统登录</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header class="hero slim">
|
||||
<div>
|
||||
<h1>库存系统登录</h1>
|
||||
<p>请输入用户名和密码后继续使用系统</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="panel" style="max-width: 520px; margin: 0 auto;">
|
||||
{% if error %}
|
||||
<p class="alert">{{ error }}</p>
|
||||
{% endif %}
|
||||
{% if notice %}
|
||||
<p class="notice">{{ notice }}</p>
|
||||
{% endif %}
|
||||
<form class="form-grid" method="post" action="{{ url_for('login_page') }}">
|
||||
<input type="hidden" name="next" value="{{ next_path or '' }}">
|
||||
<label>
|
||||
用户名
|
||||
<input type="text" name="username" required autocomplete="username" placeholder="请输入用户名">
|
||||
</label>
|
||||
<label>
|
||||
密码
|
||||
<input type="password" name="password" required autocomplete="current-password" placeholder="请输入密码">
|
||||
</label>
|
||||
<div class="actions full">
|
||||
<button class="btn" type="submit">登录</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,6 +15,7 @@
|
||||
<nav class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('index') }}">返回首页</a>
|
||||
<a class="btn btn-light" href="{{ url_for('stats_page') }}">统计页</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<nav class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('index') }}">返回首页</a>
|
||||
<a class="btn btn-light" href="{{ url_for('search_page') }}">快速搜索</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('types_page') }}">返回仓库概览</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<a class="btn" href="{{ url_for('type_page', box_type='custom') }}#quick-add">添加容器</a>
|
||||
<a class="btn btn-light" href="{{ url_for('search_page') }}">快速搜索</a>
|
||||
<a class="btn btn-light" href="{{ url_for('stats_page') }}">统计页</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user