瀏覽代碼

Fix register

tsurumure 4 月之前
父節點
當前提交
4560ea061f

+ 8 - 9
src/main/java/com/backendsys/modules/common/config/security/utils/CaptchaUtil.java

@@ -49,15 +49,14 @@ public class CaptchaUtil {
      * 校验 验证码
      */
     public Boolean isCaptchaValid(String captcha, String captchaRedisKey) {
-//        // 如果不是本地开发环境,则执行以下判断
-//        String profileActive = env.getProperty("spring.profiles.active");
-//        if (!("local".equals(profileActive))) {
-            // 判断验证码是否正确 (是否与Redis中的验证码匹配) (测试环境忽略)
-            String captchaRedisValue = redisUtil.getCacheObject(captchaRedisKey);
-            if (captchaRedisValue == null || !captchaRedisValue.equalsIgnoreCase(captcha)) {
-                return false;
-            }
-//        }
+
+        String captchaRedisValue = redisUtil.getCacheObject(captchaRedisKey);
+        System.out.println("captchaRedisKey = " + captchaRedisKey);
+        System.out.println("captcha = " + captcha);
+        System.out.println("captchaRedisValue = " + captchaRedisValue);
+        if (captchaRedisValue == null || !captchaRedisValue.equalsIgnoreCase(captcha)) {
+            return false;
+        }
         return true;
     }
 

+ 10 - 8
src/main/java/com/backendsys/modules/system/service/impl/SysAuthServiceImpl.java

@@ -271,10 +271,6 @@ public class SysAuthServiceImpl implements SysAuthService {
         // 判断短信验证码是否正确
         String redisKey = APPLICATION_NAME + "-sms-login" + "-" + phone;
         Integer smsCode = redisUtil.getCacheObject(redisKey);
-
-        System.out.println("APPLICATION_NAME = " + APPLICATION_NAME);
-        System.out.println("redisKey = " + redisKey);
-        System.out.println("smsCode = " + smsCode);
         // 判断是否发送验证码
         if ("false".equals(SMS_DEBUG) && smsCode == null) throw new CustException("请先发送验证码");
         // 判断短信验证码是否错误
@@ -318,7 +314,6 @@ public class SysAuthServiceImpl implements SysAuthService {
         // 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
         lockStatusUtil.checkLockStatus(APPLICATION_NAME + "-register-error", username);
         lockStatusUtil.checkLockStatus(APPLICATION_NAME + "-register-error", phone);
-
         // 判断图形验证码是否正确
         if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
             loginFail("验证码错误", username, false);
@@ -330,7 +325,7 @@ public class SysAuthServiceImpl implements SysAuthService {
         if (sysUser1 != null) throw new CustException("用户名 (" + username + ") 已被注册");
         
         // 判断短信验证码是否正确
-        String redisKey = APPLICATION_NAME + "-sms-login" + "-" + phone;
+        String redisKey = APPLICATION_NAME + "-sms-register" + "-" + phone;
         Integer smsCode = redisUtil.getCacheObject(redisKey);
         // 判断是否发送验证码
         if ("false".equals(SMS_DEBUG) && smsCode == null) throw new CustException("请先发送验证码");
@@ -357,8 +352,15 @@ public class SysAuthServiceImpl implements SysAuthService {
         registerEntity.setPhone(sysUserDTO.getPhone());
         registerEntity.setPhone_area_code(sysUserDTO.getPhone_area_code());
         registerEntity.setPassword(sysUserDTO.getPassword());
-        // 注册时,默认使用 游客 2L 权限
-        registerEntity.setRole_id(Arrays.asList(2L));
+
+
+        // 做成后台可控制?
+
+        // 注册时,默认使用 权限
+        registerEntity.setRole_id(Arrays.asList(3L));
+
+
+
         registerEntity.setInvite_code(sysUserDTO.getInvite_code());
         // 注册时,状态为禁用
         registerEntity.setStatus(-1);