| | |
| | | redisTemplate.delete(token); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updatePwd(Integer shopId, String oldPassword, String newPassword){ |
| | | if(StringUtils.isBlank(oldPassword) || StringUtils.isBlank(newPassword)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "旧密码和新密码不能为空"); |
| | | } |
| | | if(oldPassword.equals(newPassword)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "新密码不能与旧密码相同"); |
| | | } |
| | | Shop shop = shopMapper.selectById(shopId); |
| | | if(shop == null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "商户信息不存在"); |
| | | } |
| | | String oldPwd = Utils.Secure.encryptPassword(oldPassword, shop.getSalt()); |
| | | if(!oldPwd.equals(shop.getPassword())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "旧密码错误"); |
| | | } |
| | | String newSalt = RandomStringUtils.randomAlphabetic(6); |
| | | String newPwd = Utils.Secure.encryptPassword(newPassword, newSalt); |
| | | shopMapper.update(null, new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getPassword, newPwd) |
| | | .set(Shop::getSalt, newSalt) |
| | | .eq(Shop::getId, shopId)); |
| | | } |
| | | |
| | | |
| | | } |