fix(shopping): 修复报价密码存储和验证逻辑

- 移除了 Redis 键中多余的冒号后缀
- 在密码验证失败时返回编码后的默认密码
- 确保所有密码操作都经过编码处理
This commit is contained in:
曹鹏飞 2026-03-26 08:59:03 +08:00
parent 2db60b5539
commit f0ce531a44
1 changed files with 3 additions and 3 deletions

View File

@ -869,7 +869,7 @@ public class ShoppingController extends ControllerBase {
*/ */
@PostMapping("/setPassword") @PostMapping("/setPassword")
public ApiResult<Void> setPassword(@RequestBody String password) { public ApiResult<Void> setPassword(@RequestBody String password) {
stringRedisTemplate.opsForHash().put("quotation:password:", String.valueOf(AppUserUtil.getUserId()), PASSWORDENCODER.encode(password)); stringRedisTemplate.opsForHash().put("quotation:password", String.valueOf(AppUserUtil.getUserId()), PASSWORDENCODER.encode(password));
return ApiResult.success(); return ApiResult.success();
} }
@ -878,10 +878,10 @@ public class ShoppingController extends ControllerBase {
*/ */
@PostMapping("/validatePassword") @PostMapping("/validatePassword")
public ApiResult<Boolean> validatePassword(@RequestBody String password) { public ApiResult<Boolean> validatePassword(@RequestBody String password) {
Object pwd = stringRedisTemplate.opsForHash().get("quotation:password:", String.valueOf(AppUserUtil.getUserId())); Object pwd = stringRedisTemplate.opsForHash().get("quotation:password", String.valueOf(AppUserUtil.getUserId()));
// VUtils.trueThrowBusinessError(Objects.isNull(pwd)).throwMessage("还未设置过查看密码"); // VUtils.trueThrowBusinessError(Objects.isNull(pwd)).throwMessage("还未设置过查看密码");
if (Objects.isNull(pwd)) { if (Objects.isNull(pwd)) {
pwd = "000000"; pwd = PASSWORDENCODER.encode("000000");
} }
if (!PASSWORDENCODER.matches(password, pwd.toString())) { if (!PASSWORDENCODER.matches(password, pwd.toString())) {
return ApiResult.error("查看密码不正确"); return ApiResult.error("查看密码不正确");