Selaa lähdekoodia

bugfix:用旧密码修改密码失败

lyx 1 kuukausi sitten
vanhempi
commit
ac8c857c87

+ 10 - 3
alien-store/src/main/java/shop/alien/store/controller/StoreUserController.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreImg;
@@ -62,7 +63,13 @@ public class StoreUserController {
 
     @ApiOperation("修改密码/忘记密码/更换绑定手机号")
     @ApiOperationSupport(order = 2)
-    @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "newPhone", value = "新手机号", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "newPassword", value = "新密码", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "confirmNewPassword", value = "新密码确认", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "类型:0:忘记密码,1:修改密码,2:更换绑定手机号", dataType = "Integer", paramType = "query", required = true)})
+    @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "newPhone", value = "新手机号", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "oldPassword", value = "旧密码", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "newPassword", value = "新密码", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "confirmNewPassword", value = "新密码确认", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "verificationCode", value = "验证码", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "type", value = "类型:0:忘记密码,1:修改密码,2:更换绑定手机号", dataType = "Integer", paramType = "query", required = true)})
     @GetMapping("/updatePassword")
     public R<String> updatePassword(String phone, String newPhone, String oldPassword, String newPassword, String confirmNewPassword, String verificationCode, Integer type) {
         log.info("StoreUserController.updatePassword?phone={}&newPhone={}&oldPassword={}&newPassword={}&confirmNewPassword={}&verificationCode={}&type={}", phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);
@@ -80,10 +87,10 @@ public class StoreUserController {
                 break;
         }
         String cacheCode = baseRedisService.getString("verification_store_" + businessType + "_" + phone);
-        if (null == cacheCode) {
+        if (StringUtils.isBlank(oldPassword) && null == cacheCode) {
             return R.fail("当验证码过期或未发送");
         }
-        if (!cacheCode.trim().equals(verificationCode.trim())) {
+        if (StringUtils.isBlank(oldPassword) && !cacheCode.trim().equals(verificationCode.trim())) {
             return R.fail("验证码错误");
         }
         return storeUserService.forgetOrModifyPassword(phone, newPhone, oldPassword, newPassword, confirmNewPassword, verificationCode, type);