fix(system): 优化用户修改邮箱和手机号功能
- 在 EmailUpdateForm 和 MobileUpdateForm 中添加了 @NotBlank 注解,确保邮箱和手机号不能为空 - 在 UserServiceImpl 中增加了验证码过期检查和验证完成后删除验证码的逻辑 - 优化了错误提示信息,提高用户体验
This commit is contained in:
@@ -451,9 +451,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
String redisCacheKey = RedisConstants.SMS_CHANGE_CODE_PREFIX + mobile;
|
||||
String cachedVerifyCode = redisTemplate.opsForValue().get(redisCacheKey);
|
||||
|
||||
if (StrUtil.isBlank(cachedVerifyCode)) {
|
||||
throw new BusinessException("验证码已过期");
|
||||
}
|
||||
if (!inputVerifyCode.equals(cachedVerifyCode)) {
|
||||
throw new BusinessException("验证码错误");
|
||||
}
|
||||
// 验证完成删除验证码
|
||||
redisTemplate.delete(redisCacheKey);
|
||||
|
||||
// 更新手机号码
|
||||
return this.update(
|
||||
@@ -505,9 +510,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
String redisCacheKey = RedisConstants.EMAIL_CHANGE_CODE_PREFIX + email;
|
||||
String cachedVerifyCode = redisTemplate.opsForValue().get(redisCacheKey);
|
||||
|
||||
if (StrUtil.isBlank(cachedVerifyCode)) {
|
||||
throw new BusinessException("验证码已过期");
|
||||
}
|
||||
|
||||
if (!inputVerifyCode.equals(cachedVerifyCode)) {
|
||||
throw new BusinessException("验证码错误");
|
||||
}
|
||||
// 验证完成删除验证码
|
||||
redisTemplate.delete(redisCacheKey);
|
||||
|
||||
// 更新邮箱地址
|
||||
return this.update(
|
||||
|
||||
Reference in New Issue
Block a user