diff --git a/src/core/login_core/login_core.service.ts b/src/core/login_core/login_core.service.ts index 3d52626..a53f79f 100644 --- a/src/core/login_core/login_core.service.ts +++ b/src/core/login_core/login_core.service.ts @@ -239,6 +239,19 @@ export class LoginCoreService { email_verified: email ? true : false // 如果提供了邮箱且验证码验证通过,则标记为已验证 }); + // 注册成功后清除验证码冷却时间,方便用户后续操作 + if (email) { + try { + await this.verificationService.clearCooldown( + email, + VerificationCodeType.EMAIL_VERIFICATION + ); + } catch (error) { + // 清除冷却时间失败不影响注册流程,只记录日志 + console.warn(`清除验证码冷却时间失败: ${email}`, error); + } + } + // 如果提供了邮箱,发送欢迎邮件 if (email) { try { @@ -417,9 +430,22 @@ export class LoginCoreService { const passwordHash = await this.hashPassword(newPassword); // 更新密码 - return await this.usersService.update(user.id, { + const updatedUser = await this.usersService.update(user.id, { password_hash: passwordHash }); + + // 密码重置成功后清除验证码冷却时间 + try { + await this.verificationService.clearCooldown( + identifier, + VerificationCodeType.PASSWORD_RESET + ); + } catch (error) { + // 清除冷却时间失败不影响重置流程,只记录日志 + console.warn(`清除验证码冷却时间失败: ${identifier}`, error); + } + + return updatedUser; } /** @@ -701,7 +727,15 @@ export class LoginCoreService { throw error; } - // 5. 验证成功,返回用户信息 + // 5. 验证成功后清除验证码冷却时间 + try { + await this.verificationService.clearCooldown(identifier, verificationType); + } catch (error) { + // 清除冷却时间失败不影响登录流程,只记录日志 + console.warn(`清除验证码冷却时间失败: ${identifier}`, error); + } + + // 6. 验证成功,返回用户信息 return { user, isNewUser: false