feat: add user settings page (change username/password) and remove public registration
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}API Keys - Postcard Manager{% endblock %}
|
||||
{% block content %}
|
||||
<div class="section-header">
|
||||
<h1>API Keys</h1>
|
||||
<form method="post" action="/api-keys">
|
||||
<button type="submit" class="btn btn-primary">+ 创建新 Key</button>
|
||||
</form>
|
||||
</div>
|
||||
{% if keys %}
|
||||
<table>
|
||||
<thead><tr><th>Key</th><th>创建时间</th><th>操作</th></tr></thead>
|
||||
<tbody>
|
||||
{% for k in keys %}
|
||||
<tr>
|
||||
<td><code>{{ k.key }}</code></td>
|
||||
<td>{{ k.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
<td>
|
||||
<form method="post" action="/api-keys/{{ k.id }}/delete" class="inline">
|
||||
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确定删除该 Key?')">删除</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="empty">还没有 API Key,点击上方按钮创建一个。</p>
|
||||
{% endif %}
|
||||
<section class="section" style="margin-top:2rem">
|
||||
<h2>使用说明</h2>
|
||||
<pre>curl -H "Authorization: Bearer YOUR_API_KEY" http://localhost:8000/api/profiles</pre>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="nav-links">
|
||||
{% if user is defined and user %}
|
||||
<a href="/profiles">Profiles</a>
|
||||
<a href="/api-keys">API Keys</a>
|
||||
<a href="/settings">Settings</a>
|
||||
<a href="/logout" class="nav-logout">Logout</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,5 @@
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary">登录</button>
|
||||
</form>
|
||||
<p class="auth-link">没有账号?<a href="/register">注册</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}注册 - Postcard Manager{% endblock %}
|
||||
{% block content %}
|
||||
<div class="auth-form">
|
||||
<h2>注册</h2>
|
||||
{% if error %}
|
||||
<div class="alert alert-error">{{ error }}</div>
|
||||
{% endif %}
|
||||
<form method="post" action="/register">
|
||||
<label>用户名</label>
|
||||
<input type="text" name="username" required autofocus>
|
||||
<label>密码</label>
|
||||
<input type="password" name="password" required>
|
||||
<label>确认密码</label>
|
||||
<input type="password" name="password2" required>
|
||||
<button type="submit" class="btn btn-primary">注册</button>
|
||||
</form>
|
||||
<p class="auth-link">已有账号?<a href="/login">登录</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
44
app/templates/settings.html
Normal file
44
app/templates/settings.html
Normal file
@@ -0,0 +1,44 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}用户设置 - Postcard Manager{% endblock %}
|
||||
{% block content %}
|
||||
<div class="section-header">
|
||||
<h1>用户设置</h1>
|
||||
</div>
|
||||
|
||||
{% if success %}
|
||||
<div class="alert alert-success">{{ success }}</div>
|
||||
{% endif %}
|
||||
{% if error %}
|
||||
<div class="alert alert-error">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-card" style="max-width:400px">
|
||||
<h3 style="margin-bottom:.75rem">修改用户名</h3>
|
||||
<form method="post" action="/settings/change-username">
|
||||
<label>当前用户名</label>
|
||||
<input type="text" value="{{ user.username }}" disabled>
|
||||
<label>新用户名</label>
|
||||
<input type="text" name="new_username" required maxlength="64" placeholder="输入新用户名">
|
||||
<label>确认密码</label>
|
||||
<input type="password" name="password" required placeholder="输入当前密码确认身份">
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">修改用户名</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="max-width:400px;margin-top:1.5rem">
|
||||
<h3 style="margin-bottom:.75rem">修改密码</h3>
|
||||
<form method="post" action="/settings/change-password">
|
||||
<label>当前密码</label>
|
||||
<input type="password" name="old_password" required placeholder="输入当前密码">
|
||||
<label>新密码</label>
|
||||
<input type="password" name="new_password" required placeholder="输入新密码">
|
||||
<label>确认新密码</label>
|
||||
<input type="password" name="confirm_password" required placeholder="再次输入新密码">
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">修改密码</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user