v4.1 管理员邮箱绑定与SMTP找回密码
1. users 表新增 email 列,管理员添加/编辑支持绑定邮箱,修改密码页支持自助绑定 2. 新增 SMTP 邮件发送工具与配置(FRONTEND_URL/SMTP_* 等) 3. 新增忘记密码/重置密码公开接口与页面:一次性令牌、30分钟有效、请求限流、重置后强制重新登录 4. 登录与 /api/auth/me 返回邮箱并同步 PHP Session 5. 版本升级至4.1(sql/upgrades/v4.1.sql)
This commit is contained in:
1 parent
3588b4c28c
commit
058dee9dc4
31 files changed
+762
-34
No files matched your search
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* 班级操行分管理系统 - 忘记密码
|
||||
*
|
||||
* 开发者: Canglan
|
||||
* 联系方式: admin@sea-studio.top
|
||||
* 版权归属: Sea Network Technology Studio
|
||||
* 许可证: MIT License
|
||||
*
|
||||
* 版权所有 © Sea Network Technology Studio
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title><?php echo SITE_NAME; ?> - 忘记密码</title>
|
||||
<link rel="stylesheet" href="/assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="login-header">
|
||||
<h1><?php echo SITE_NAME; ?></h1>
|
||||
<p>管理员找回密码</p>
|
||||
</div>
|
||||
|
||||
<form id="forgotForm" class="login-form">
|
||||
<div class="form-group">
|
||||
<label>管理员账号</label>
|
||||
<input type="text" id="username" name="username" required autocomplete="off" placeholder="请输入管理员用户名">
|
||||
<small>重置链接将发送到该账号绑定的邮箱</small>
|
||||
</div>
|
||||
<button type="submit" class="btn-login" id="submitBtn">发送重置链接</button>
|
||||
<div id="tipMsg" class="error-msg" style="display: none;"></div>
|
||||
<p style="text-align:center; margin-top:14px;">
|
||||
<a href="/index.php" style="color:#667eea; font-size:14px;">返回登录</a>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<div class="login-footer">
|
||||
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio</p>
|
||||
<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?>
|
||||
<p><a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.API_BASE_URL = '<?php echo API_BASE_URL; ?>';
|
||||
|
||||
function showTip(msg, isError) {
|
||||
const tip = document.getElementById('tipMsg');
|
||||
tip.textContent = msg;
|
||||
tip.style.display = 'block';
|
||||
tip.style.color = isError ? '' : '#38a169';
|
||||
}
|
||||
|
||||
document.getElementById('forgotForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('username').value.trim();
|
||||
if (!username) {
|
||||
showTip('请输入管理员账号', true);
|
||||
return;
|
||||
}
|
||||
const btn = document.getElementById('submitBtn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '发送中...';
|
||||
try {
|
||||
const response = await fetch(`${window.API_BASE_URL}/api/auth/forgot-password`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username })
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
showTip(data.message || '重置链接已发送,请查收邮箱', false);
|
||||
} else {
|
||||
showTip(data.message || '发送失败', true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('找回密码请求失败:', error);
|
||||
showTip('网络错误,请稍后重试', true);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '发送重置链接';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user