feat: SSR 忘记密码与 Admin SMTP 设置
邮箱验证码重置密码(吊销 session);后台可配 SMTP 并发送测试信。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -38,6 +38,32 @@
|
||||
<label>词表 <textarea name="filter_words" rows="12">{{.FilterWords}}</textarea></label>
|
||||
<button type="submit">保存敏感词</button>
|
||||
</form>
|
||||
|
||||
<h2>邮件 SMTP</h2>
|
||||
<p class="j13-muted">启用后可用于注册验证码、忘记密码重置与通知。{{if .MailReady}}当前:已就绪。{{else}}当前:未就绪。{{end}}{{if .Mail.HasPassword}} 已保存密码。{{end}}</p>
|
||||
<form method="post" action="/admin/settings/mail" class="j13-form j13-admin-form">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<label class="j13-check"><input type="checkbox" name="enabled" value="1"{{if .Mail.Enabled}} checked{{end}}/> 启用邮件</label>
|
||||
<label>SMTP Host <input name="host" value="{{.Mail.Host}}" placeholder="smtp.example.com"/></label>
|
||||
<label>端口 <input name="port" type="number" min="1" value="{{.Mail.Port}}"/></label>
|
||||
<label>加密
|
||||
<select name="encryption">
|
||||
<option value="ssl"{{if eq .Mail.Encryption "ssl"}} selected{{end}}>SSL</option>
|
||||
<option value="starttls"{{if eq .Mail.Encryption "starttls"}} selected{{end}}>STARTTLS</option>
|
||||
<option value="none"{{if eq .Mail.Encryption "none"}} selected{{end}}>无</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>用户名 <input name="username" value="{{.Mail.Username}}" autocomplete="off"/></label>
|
||||
<label>密码 <input name="password" type="password" value="" autocomplete="new-password" placeholder="留空表示不修改"/></label>
|
||||
<label>发件人 From <input name="from" type="email" value="{{.Mail.From}}"/></label>
|
||||
<label>发件人显示名 <input name="from_name" value="{{.Mail.FromName}}"/></label>
|
||||
<button type="submit">保存邮件设置</button>
|
||||
</form>
|
||||
<form method="post" action="/admin/settings/mail/test" class="j13-form j13-admin-form">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<label>测试收件邮箱 <input name="test_to" type="email" required placeholder="you@example.com"/></label>
|
||||
<button type="submit" class="j13-btn-secondary">发送测试信</button>
|
||||
</form>
|
||||
</main>
|
||||
{{template "base/footer" .}}
|
||||
{{end}}
|
||||
|
||||
33
templates/auth/forgot_password.tmpl
Normal file
33
templates/auth/forgot_password.tmpl
Normal file
@@ -0,0 +1,33 @@
|
||||
{{define "auth/forgot_password"}}
|
||||
{{template "base/head" .}}
|
||||
<main class="j13-main j13-main--solo j13-auth">
|
||||
<h1>忘记密码</h1>
|
||||
{{template "base/alert" .}}
|
||||
{{if .MailReady}}
|
||||
<form method="post" action="/forgot-password" class="j13-form" id="forgot-form">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<label>注册邮箱
|
||||
<input type="email" name="email" required autocomplete="email" value="{{.Email}}"/>
|
||||
</label>
|
||||
<label>邮箱验证码
|
||||
<div class="j13-form__row">
|
||||
<input name="email_code" required inputmode="numeric" autocomplete="one-time-code" maxlength="8"/>
|
||||
<button type="submit" formaction="/forgot-password/send-code" formnovalidate class="j13-btn-secondary">发送验证码</button>
|
||||
</div>
|
||||
</label>
|
||||
<label>新密码
|
||||
<input type="password" name="new_password" required autocomplete="new-password" minlength="6"/>
|
||||
</label>
|
||||
<label>确认新密码
|
||||
<input type="password" name="new_password2" required autocomplete="new-password" minlength="6"/>
|
||||
</label>
|
||||
<button type="submit">重置密码</button>
|
||||
</form>
|
||||
<p class="j13-muted">若该邮箱已注册,验证码将发送到邮箱。重置后其它设备会话将失效。</p>
|
||||
{{else}}
|
||||
<p class="j13-muted">邮件服务未配置,无法通过邮箱重置密码。请联系站长在后台配置 SMTP,或使用其它方式找回。</p>
|
||||
{{end}}
|
||||
<p><a href="/login">返回登录</a> · <a href="/">返回首页</a></p>
|
||||
</main>
|
||||
{{template "base/footer" .}}
|
||||
{{end}}
|
||||
@@ -14,7 +14,7 @@
|
||||
</label>
|
||||
<button type="submit">登录</button>
|
||||
</form>
|
||||
<p><a href="/register">没有账号?注册</a> · <a href="/">返回首页</a></p>
|
||||
<p><a href="/register">没有账号?注册</a> · <a href="/forgot-password">忘记密码</a> · <a href="/">返回首页</a></p>
|
||||
</main>
|
||||
{{template "base/footer" .}}
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user