|
@@ -252,10 +252,12 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
public Map<String, String> changePhoneVerification(String phone, String oldPassword, String verificationCode) {
|
|
public Map<String, String> changePhoneVerification(String phone, String oldPassword, String verificationCode) {
|
|
|
Map<String, String> changePhoneMap = new HashMap<>();
|
|
Map<String, String> changePhoneMap = new HashMap<>();
|
|
|
if (oldPassword != null && !oldPassword.equals("")) {
|
|
if (oldPassword != null && !oldPassword.equals("")) {
|
|
|
- LambdaUpdateWrapper<StoreUser> userLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
- userLambdaUpdateWrapper.eq(StoreUser::getPhone, phone);
|
|
|
|
|
- StoreUser storeUser = this.getOne(userLambdaUpdateWrapper);
|
|
|
|
|
- if (storeUser.getPassword().equals(oldPassword)) {
|
|
|
|
|
|
|
+ LambdaQueryWrapper<StoreUser> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ userLambdaQueryWrapper.eq(StoreUser::getPhone, phone);
|
|
|
|
|
+ StoreUser storeUser = this.getOne(userLambdaQueryWrapper);
|
|
|
|
|
+ // 由于password字段使用了EncryptTypeHandler,查询时密码会被自动解密
|
|
|
|
|
+ // 所以这里直接比较解密后的密码和用户输入的明文密码
|
|
|
|
|
+ if (storeUser != null && storeUser.getPassword() != null && storeUser.getPassword().equals(oldPassword)) {
|
|
|
changePhoneMap.put("passwordStatus", "1");
|
|
changePhoneMap.put("passwordStatus", "1");
|
|
|
return changePhoneMap;
|
|
return changePhoneMap;
|
|
|
} else {
|
|
} else {
|
|
@@ -269,7 +271,7 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void passwordVerification(String phone, String password, String newPassword, String confirmNewPassword) {
|
|
private void passwordVerification(String phone, String password, String newPassword, String confirmNewPassword) {
|
|
|
- LambdaUpdateWrapper<StoreUser> wrapperFans = new LambdaUpdateWrapper<>();
|
|
|
|
|
|
|
+ LambdaQueryWrapper<StoreUser> wrapperFans = new LambdaQueryWrapper<>();
|
|
|
wrapperFans.eq(StoreUser::getPhone, phone);
|
|
wrapperFans.eq(StoreUser::getPhone, phone);
|
|
|
StoreUser storeUser = this.getOne(wrapperFans);
|
|
StoreUser storeUser = this.getOne(wrapperFans);
|
|
|
if (!newPassword.equals(confirmNewPassword)) {
|
|
if (!newPassword.equals(confirmNewPassword)) {
|
|
@@ -280,9 +282,10 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
log.info("该手机号没有注册过账户");
|
|
log.info("该手机号没有注册过账户");
|
|
|
throw new RuntimeException("该手机号没有注册过账户");
|
|
throw new RuntimeException("该手机号没有注册过账户");
|
|
|
} else {
|
|
} else {
|
|
|
- wrapperFans.eq(StoreUser::getPassword, password);
|
|
|
|
|
- StoreUser storeUserPw = this.getOne(wrapperFans);
|
|
|
|
|
- if (storeUserPw == null || storeUserPw.getPassword().equals("")) {
|
|
|
|
|
|
|
+ // 由于password字段使用了EncryptTypeHandler,查询时密码会被自动解密
|
|
|
|
|
+ // 所以这里直接比较解密后的密码和用户输入的明文密码
|
|
|
|
|
+ String dbPassword = storeUser.getPassword();
|
|
|
|
|
+ if (dbPassword == null || dbPassword.isEmpty() || !dbPassword.equals(password)) {
|
|
|
log.info("原密码错误");
|
|
log.info("原密码错误");
|
|
|
throw new RuntimeException("原密码错误");
|
|
throw new RuntimeException("原密码错误");
|
|
|
}
|
|
}
|