From 773b497761733634856e07e5eb432ef9283b5753 Mon Sep 17 00:00:00 2001 From: yangs <1692700664@qq.com> Date: Thu, 30 Mar 2023 10:52:49 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/system/service/SysLoginService.java | 7 ++----- .../com/ruoyi/system/service/SysRegisterService.java | 9 ++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java index 3c29b85cf..2a225cb4a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java @@ -32,7 +32,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; import java.time.Duration; import java.util.List; import java.util.function.Supplier; @@ -67,11 +66,10 @@ public class SysLoginService { * @return 结果 */ public String login(String username, String password, String code, String uuid) { - HttpServletRequest request = ServletUtils.getRequest(); boolean captchaEnabled = configService.selectCaptchaEnabled(); // 验证码开关 if (captchaEnabled) { - validateCaptcha(username, code, uuid, request); + validateCaptcha(username, code, uuid); } SysUser user = loadUserByUsername(username); checkLogin(LoginType.PASSWORD, username, () -> !BCrypt.checkpw(password, user.getPassword())); @@ -140,7 +138,6 @@ public class SysLoginService { * @param username 用户名 * @param status 状态 * @param message 消息内容 - * @return */ private void recordLogininfor(String username, String status, String message) { LogininforEvent logininforEvent = new LogininforEvent(); @@ -170,7 +167,7 @@ public class SysLoginService { * @param code 验证码 * @param uuid 唯一标识 */ - public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) { + public void validateCaptcha(String username, String code, String uuid) { String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, ""); String captcha = RedisUtils.getCacheObject(verifyKey); RedisUtils.deleteObject(verifyKey); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysRegisterService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysRegisterService.java index 886aec3b8..1a034e569 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysRegisterService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysRegisterService.java @@ -3,7 +3,6 @@ package com.ruoyi.system.service; import cn.dev33.satoken.secure.BCrypt; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.event.LogininforEvent; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.RegisterBody; @@ -19,8 +18,6 @@ import com.ruoyi.common.utils.spring.SpringUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; - /** * 注册校验方法 * @@ -37,7 +34,6 @@ public class SysRegisterService { * 注册 */ public void register(RegisterBody registerBody) { - HttpServletRequest request = ServletUtils.getRequest(); String username = registerBody.getUsername(); String password = registerBody.getPassword(); // 校验用户类型是否存在 @@ -46,7 +42,7 @@ public class SysRegisterService { boolean captchaEnabled = configService.selectCaptchaEnabled(); // 验证码开关 if (captchaEnabled) { - validateCaptcha(username, registerBody.getCode(), registerBody.getUuid(), request); + validateCaptcha(username, registerBody.getCode(), registerBody.getUuid()); } SysUser sysUser = new SysUser(); sysUser.setUserName(username); @@ -70,9 +66,8 @@ public class SysRegisterService { * @param username 用户名 * @param code 验证码 * @param uuid 唯一标识 - * @return 结果 */ - public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) { + public void validateCaptcha(String username, String code, String uuid) { String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, ""); String captcha = RedisUtils.getCacheObject(verifyKey); RedisUtils.deleteObject(verifyKey);