feat:添加验证码冷却时间清除功能
新增 clearCooldown 方法,用于在用户成功完成操作后 清除验证码冷却时间,提升用户体验: - 注册成功后清除邮箱验证码冷却时间 - 密码重置成功后清除重置验证码冷却时间 - 验证码登录成功后清除登录验证码冷却时间
This commit is contained in:
@@ -294,6 +294,18 @@ export class VerificationService {
|
||||
return `verification_hourly:${type}:${identifier}:${date}:${hour}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除验证码冷却时间
|
||||
*
|
||||
* @param identifier 标识符
|
||||
* @param type 验证码类型
|
||||
*/
|
||||
async clearCooldown(identifier: string, type: VerificationCodeType): Promise<void> {
|
||||
const cooldownKey = this.buildCooldownKey(identifier, type);
|
||||
await this.redis.del(cooldownKey);
|
||||
this.logger.log(`验证码冷却时间已清除: ${identifier} (${type})`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理过期的验证码(可选的定时任务)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user