Files
alterminal/internal/auth/templates/password.html
T
2026-10-03 12:37:38 +08:00

70 lines
4.5 KiB
HTML

{{/* 更新密碼頁(登入者自助變更,GET/POST /password)。以 layout.html
(側邊導覽欄版面)為根模板組合渲染,本檔僅定義區塊,不應單獨解析
執行。導覽覆寫版面預設:「帳號資訊」不標記 aria-current(本頁非
帳號首頁),admin 另顯示管理頁連結。密碼欄位一律不預填——驗證失敗
重繪亦同;成功後 PRG 回本頁以 ?saved=1 顯示成功訊息。 */}}
{{define "title"}}更新密碼 - alterminal{{end}}
{{define "navitems"}}
<li>
<a href="/"
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-700/60">
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"/>
</svg>
帳號資訊
</a>
</li>
{{if .IsAdmin}}
<li>
<a href="/admin/keys"
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-700/60">
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"/>
</svg>
金鑰管理
</a>
</li>
<li>
<a href="/admin/applications"
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-700/60">
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9"/>
</svg>
應用程式管理
</a>
</li>
{{end}}
{{end}}
{{define "content"}}
<section class="rounded-xl bg-white p-8 shadow-lg dark:bg-neutral-800 dark:shadow-black/40">
<h1 class="mb-1 text-xl font-semibold">更新密碼</h1>
<p class="mb-6 text-sm text-neutral-500 dark:text-neutral-400">驗證目前的密碼後設定新密碼</p>
{{if .Error}}<p class="mb-4 rounded-lg bg-red-500/10 px-3 py-2.5 text-sm text-red-600 dark:text-red-400" role="alert">{{.Error}}</p>{{end}}
{{if .Success}}<p class="mb-4 rounded-lg bg-emerald-500/10 px-3 py-2.5 text-sm text-emerald-700 dark:text-emerald-400" role="status">{{.Success}}</p>{{end}}
<form method="post" action="/password" class="space-y-4">
<input type="hidden" name="csrf_token" value="{{.CSRF}}">
<div>
<label for="current-password" class="mb-1 block text-sm font-medium">目前的密碼</label>
<input type="password" id="current-password" name="current_password" autocomplete="current-password" autofocus required
class="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-900">
</div>
<div>
<label for="new-password" class="mb-1 block text-sm font-medium">新密碼</label>
<input type="password" id="new-password" name="new_password" autocomplete="new-password" minlength="8" required
class="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-900">
<p class="mt-1 text-xs text-neutral-500 dark:text-neutral-400">至少 8 字元。</p>
</div>
<div>
<label for="confirm-password" class="mb-1 block text-sm font-medium">確認新密碼</label>
<input type="password" id="confirm-password" name="confirm_password" autocomplete="new-password" minlength="8" required
class="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-900">
</div>
<button type="submit"
class="rounded-lg bg-brand px-4 py-2.5 text-sm font-semibold text-white hover:bg-brand-strong">更新密碼</button>
</form>
<p class="mt-4 text-xs text-neutral-400 dark:text-neutral-500">更新成功後,其他裝置的登入將全部登出;本瀏覽器會保持登入狀態。</p>
</section>
{{end}}