mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 01:13:52 +08:00
Merge pull request #3006 from xinnan-tech/captcha-validation-error
fix: 优化验证码验证错误提示
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user