From bed1e7c4af65149e4d1241a7eaf92327123049ac Mon Sep 17 00:00:00 2001 From: Yjoioooo <693337446@qq.com> Date: Wed, 26 Apr 2023 17:34:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81=E7=A0=81key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/auth/service/SysLoginService.java | 5 +++-- .../dromara/resource/controller/SysEmailController.java | 8 ++++---- .../org/dromara/resource/controller/SysSmsController.java | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java index 01c3bed0..c197437b 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java @@ -11,6 +11,7 @@ import org.dromara.auth.form.RegisterBody; import org.dromara.auth.properties.UserPasswordProperties; import org.dromara.common.core.constant.CacheConstants; import org.dromara.common.core.constant.Constants; +import org.dromara.common.core.constant.GlobalConstants; import org.dromara.common.core.constant.TenantConstants; import org.dromara.common.core.enums.DeviceType; import org.dromara.common.core.enums.LoginType; @@ -177,7 +178,7 @@ public class SysLoginService { * 校验短信验证码 */ private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) { - String code = RedisUtils.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + phonenumber); + String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phonenumber); if (StringUtils.isBlank(code)) { recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")); throw new CaptchaExpireException(); @@ -189,7 +190,7 @@ public class SysLoginService { * 校验邮箱验证码 */ private boolean validateEmailCode(String tenantId, String email, String emailCode) { - String code = RedisUtils.getCacheObject(CacheConstants.CAPTCHA_CODE_KEY + email); + String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + email); if (StringUtils.isBlank(code)) { recordLogininfor(tenantId, email, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")); throw new CaptchaExpireException(); diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysEmailController.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysEmailController.java index 3751bf5f..1edbcca6 100644 --- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysEmailController.java +++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysEmailController.java @@ -2,15 +2,15 @@ package org.dromara.resource.controller; import cn.hutool.core.util.RandomUtil; -import org.dromara.common.core.constant.CacheConstants; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.Constants; +import org.dromara.common.core.constant.GlobalConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.web.controller.BaseController; import org.dromara.common.mail.config.properties.MailProperties; import org.dromara.common.mail.utils.MailUtils; import org.dromara.common.redis.utils.RedisUtils; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -43,7 +43,7 @@ public class SysEmailController extends BaseController { if (!mailProperties.getEnabled()) { return R.fail("当前系统没有开启邮箱功能!"); } - String key = CacheConstants.CAPTCHA_CODE_KEY + email; + String key = GlobalConstants.CAPTCHA_CODE_KEY + email; String code = RandomUtil.randomNumbers(4); RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); try { diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysSmsController.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysSmsController.java index ceb75146..17e53286 100644 --- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysSmsController.java +++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysSmsController.java @@ -2,8 +2,10 @@ package org.dromara.resource.controller; import cn.hutool.core.util.RandomUtil; -import org.dromara.common.core.constant.CacheConstants; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.constant.Constants; +import org.dromara.common.core.constant.GlobalConstants; import org.dromara.common.core.domain.R; import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.web.controller.BaseController; @@ -11,8 +13,6 @@ import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.sms.config.properties.SmsProperties; import org.dromara.common.sms.core.SmsTemplate; import org.dromara.common.sms.entity.SmsResult; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -47,7 +47,7 @@ public class SysSmsController extends BaseController { if (!smsProperties.getEnabled()) { return R.fail("当前系统没有开启短信功能!"); } - String key = CacheConstants.CAPTCHA_CODE_KEY + phonenumber; + String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber; String code = RandomUtil.randomNumbers(4); RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); // 验证码模板id 自行处理 (查数据库或写死均可)