fix: 优化验证码验证错误提示

This commit is contained in:
rainv123 2026-03-12 17:34:04 +08:00
parent dd24dc0abc
commit 7aad8da6f6

View file

@ -20,6 +20,7 @@ public class Sm2DecryptUtil {
/** /**
* 解密SM2加密内容,提取验证码并验证 * 解密SM2加密内容,提取验证码并验证
*
* @param encryptedPassword SM2加密的密码字符串 * @param encryptedPassword SM2加密的密码字符串
* @param captchaId 验证码ID * @param captchaId 验证码ID
* @param captchaService 验证码服务 * @param captchaService 验证码服务
@ -47,13 +48,14 @@ public class Sm2DecryptUtil {
String embeddedCaptcha = decryptedContent.substring(0, CAPTCHA_LENGTH); String embeddedCaptcha = decryptedContent.substring(0, CAPTCHA_LENGTH);
String actualPassword = decryptedContent.substring(CAPTCHA_LENGTH); String actualPassword = decryptedContent.substring(CAPTCHA_LENGTH);
// 验证嵌入的验证码是否正确
boolean embeddedCaptchaValid = captchaService.validate(captchaId, embeddedCaptcha, true); boolean embeddedCaptchaValid = captchaService.validate(captchaId, embeddedCaptcha, true);
if (!embeddedCaptchaValid) { if (!embeddedCaptchaValid) {
throw new RenException(ErrorCode.SMS_CAPTCHA_ERROR); throw new RenException(ErrorCode.SMS_CAPTCHA_ERROR);
} }
return actualPassword; return actualPassword;
} else if (decryptedContent.length() > 0) {
throw new RenException(ErrorCode.SMS_CAPTCHA_ERROR);
} else { } else {
throw new RenException(ErrorCode.SM2_DECRYPT_ERROR); throw new RenException(ErrorCode.SM2_DECRYPT_ERROR);
} }