增加验证码的开关的功能
This commit is contained in:
@@ -685,6 +685,7 @@ INSERT INTO `jsh_platform_config` VALUES ('18', 'bill_excel_url', '单据Excel
|
||||
INSERT INTO `jsh_platform_config` VALUES ('19', 'email_from', '邮件发送端-发件人', '');
|
||||
INSERT INTO `jsh_platform_config` VALUES ('20', 'email_auth_code', '邮件发送端-授权码', '');
|
||||
INSERT INTO `jsh_platform_config` VALUES ('21', 'email_smtp_host', '邮件发送端-SMTP服务器', '');
|
||||
INSERT INTO `jsh_platform_config` VALUES ('22', 'checkcode_flag', '验证码启用标记', '1');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for jsh_role
|
||||
|
||||
@@ -1699,3 +1699,10 @@ alter table jsh_material change other_field3 other_field3 varchar(500) DEFAULT N
|
||||
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_from', '邮件发送端-发件人', '');
|
||||
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_auth_code', '邮件发送端-授权码', '');
|
||||
insert into jsh_platform_config (platform_key, platform_key_info, platform_value) VALUES ('email_smtp_host', '邮件发送端-SMTP服务器', '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
-- 时间 2025年9月21日
|
||||
-- by jishenghua
|
||||
-- 给平台表增加验证码启用标记
|
||||
-- --------------------------------------------------------
|
||||
insert into jsh_platform_config(platform_key, platform_key_info, platform_value) values ('checkcode_flag', '验证码启用标记', '1');
|
||||
@@ -151,6 +151,26 @@ public class PlatformConfigController extends BaseController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否开启验证码
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPlatform/checkcodeFlag")
|
||||
@ApiOperation(value = "获取是否开启验证码")
|
||||
public String getPlatformCheckcodeFlag(HttpServletRequest request)throws Exception {
|
||||
String res;
|
||||
try {
|
||||
String platformKey = "checkcode_flag";
|
||||
PlatformConfig platformConfig = platformConfigService.getInfoByKey(platformKey);
|
||||
res = platformConfig.getPlatformValue();
|
||||
} catch(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
res = "#";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据platformKey更新platformValue
|
||||
* @param object
|
||||
|
||||
@@ -288,24 +288,27 @@ public class UserService {
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public void validateCaptcha(String code, String uuid) {
|
||||
if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) {
|
||||
code = code.trim();
|
||||
uuid = uuid.trim();
|
||||
String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisService.getCacheObject(verifyKey);
|
||||
redisService.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
|
||||
public void validateCaptcha(String code, String uuid) throws Exception {
|
||||
PlatformConfig platformConfig = platformConfigService.getInfoByKey("checkcode_flag");
|
||||
if(platformConfig!=null && "1".equals(platformConfig.getPlatformValue())) {
|
||||
if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) {
|
||||
code = code.trim();
|
||||
uuid = uuid.trim();
|
||||
String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid;
|
||||
String captcha = redisService.getCacheObject(verifyKey);
|
||||
redisService.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
|
||||
}
|
||||
} else {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
|
||||
}
|
||||
} else {
|
||||
logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user