Parcourir la source

fix(customer): 恢复客户注册中的验证码验证功能

- 启用验证码校验逻辑以验证用户输入的验证码
- 恢复验证码过期检查功能
- 重新启用验证码匹配验证
- 在注册成功后清理Redis中的验证码缓存记录
- 确保验证码验证流程按预期工作
hurx il y a 3 semaines
Parent
commit
9db75b5e18

+ 11 - 11
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java

@@ -1202,14 +1202,14 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     @Transactional(rollbackFor = Exception.class)
     public Boolean register(CustomerRegisterBo bo) {
         //先校验验证码是否正确
-//        String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
-//        if (code == null) {
-//            throw new ServiceException("验证码已过期");
-//        }
-//
-//        if (!code.equals(bo.getCode())) {
-//            throw new ServiceException("验证码错误");
-//        }
+        String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
+        if (code == null) {
+            throw new ServiceException("验证码已过期");
+        }
+
+        if (!code.equals(bo.getCode())) {
+            throw new ServiceException("验证码错误");
+        }
 
         //校验密码与确认密码是否一致
         if (!bo.getPassword().equals(bo.getConfirmPassword())) {
@@ -1398,9 +1398,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
 
         log.info("客户注册成功,客户ID:{},客户名称:{}", customerId, bo.getCustomerName());
 
-//        if (null != code) {
-//            RedisUtils.deleteObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
-//        }
+        if (null != code) {
+            RedisUtils.deleteObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
+        }
         return true;
     }