🐛 修复邮箱验证和密码重置的时间戳问题

后端修复:
- 修改时间戳存储格式:从 ISO 字符串改为数值时间戳(毫秒)
- 优化时间戳比较逻辑:兼容新旧格式的时间戳
- 修复 VerificationDB.consumeVerificationToken() 的时间比较
- 修复 PasswordResetTokenDB.use() 的时间比较
- 统一使用 Date.now() 生成时间戳

前端改进:
- 新增 verifyMessage 独立显示验证相关提示
- 优化邮箱验证成功后的用户体验(自动切换到登录表单)
- 优化密码重置成功后的用户体验(自动切换到登录表单)
- 改进提示信息显示方式

技术细节:
- SQLite 时间比较:strftime('%s','now')*1000 获取当前毫秒时间戳
- 兼容旧数据:同时支持字符串和数值时间戳比较

这个修复解决了邮箱验证令牌一直提示过期的问题。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-24 15:48:32 +08:00
parent 472b98153d
commit cfbb134587
4 changed files with 29 additions and 15 deletions

View File

@@ -158,6 +158,7 @@ createApp({
// 提示信息
errorMessage: '',
successMessage: '',
verifyMessage: '',
// 存储相关
storageType: 'sftp', // 当前使用的存储类型
@@ -453,7 +454,8 @@ handleDragLeave(e) {
try {
const response = await axios.get(`${this.apiBase}/api/verify-email`, { params: { token } });
if (response.data.success) {
this.showToast('success', '成功', '邮箱验证成功,请登录');
this.verifyMessage = '邮箱验证成功,请登录';
this.isLogin = true;
// 清理URL
const url = new URL(window.location.href);
url.searchParams.delete('verifyToken');
@@ -461,7 +463,7 @@ handleDragLeave(e) {
}
} catch (error) {
console.error('邮箱验证失败:', error);
this.showToast('error', '错误', error.response?.data?.message || '验证失败');
this.verifyMessage = error.response?.data?.message || '验证失败';
}
},
@@ -1675,7 +1677,8 @@ handleDragLeave(e) {
try {
const response = await axios.post(`${this.apiBase}/api/password/reset`, this.resetPasswordForm);
if (response.data.success) {
this.showToast('success', '成功', '密码已重置,请登录');
this.verifyMessage = '密码已重置,请登录';
this.isLogin = true;
this.showResetPasswordModal = false;
this.resetPasswordForm = { token: '', new_password: '' };
// 清理URL中的token