Bladeren bron

更换手机号验证码效验

qxy 3 maanden geleden
bovenliggende
commit
85b6839b08

+ 5 - 2
alien-store/src/main/java/shop/alien/store/controller/StoreUserController.java

@@ -114,8 +114,11 @@ public class StoreUserController {
     @GetMapping("/changePhoneVerification")
     public R<Map<String, String>> changePhoneVerification(String phone, String oldPassword, String verificationCode) {
         log.info("StoreUserController.changePhoneVerification?phone={}&oldPassword={}&verificationCode={}", phone,  oldPassword,  verificationCode);
-        return R.data(storeUserService.changePhoneVerification(phone, oldPassword, verificationCode));
-
+        try {
+            return R.data(storeUserService.changePhoneVerification(phone, oldPassword, verificationCode));
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
     }
 
     @ApiOperation("修改用户信息")

+ 3 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreUserServiceImpl.java

@@ -260,6 +260,9 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
             String oldPhoneVerification = "verification_" + phone;
             //获取新手机号验证码
             String redisVerificationCode = baseRedisService.getString(oldPhoneVerification);
+            if(StringUtils.isEmpty(redisVerificationCode)){
+                throw new RuntimeException("验证码已失效 请重新获取验证码");
+            }
             if (redisVerificationCode.equals(verificationCode)) {
                 changePhoneMap.put("verificationStatus", "1");
                 return changePhoneMap;