🎨 优化未使用代码
This commit is contained in:
parent
7fd262fd8b
commit
773b497761
|
@ -32,7 +32,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -67,11 +66,10 @@ public class SysLoginService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String login(String username, String password, String code, String uuid) {
|
public String login(String username, String password, String code, String uuid) {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
|
||||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
if (captchaEnabled) {
|
if (captchaEnabled) {
|
||||||
validateCaptcha(username, code, uuid, request);
|
validateCaptcha(username, code, uuid);
|
||||||
}
|
}
|
||||||
SysUser user = loadUserByUsername(username);
|
SysUser user = loadUserByUsername(username);
|
||||||
checkLogin(LoginType.PASSWORD, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
checkLogin(LoginType.PASSWORD, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||||
|
@ -140,7 +138,6 @@ public class SysLoginService {
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param status 状态
|
* @param status 状态
|
||||||
* @param message 消息内容
|
* @param message 消息内容
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private void recordLogininfor(String username, String status, String message) {
|
private void recordLogininfor(String username, String status, String message) {
|
||||||
LogininforEvent logininforEvent = new LogininforEvent();
|
LogininforEvent logininforEvent = new LogininforEvent();
|
||||||
|
@ -170,7 +167,7 @@ public class SysLoginService {
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @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 verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
|
||||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||||
RedisUtils.deleteObject(verifyKey);
|
RedisUtils.deleteObject(verifyKey);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.ruoyi.system.service;
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constant.Constants;
|
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.event.LogininforEvent;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.RegisterBody;
|
import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||||
|
@ -19,8 +18,6 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册校验方法
|
* 注册校验方法
|
||||||
*
|
*
|
||||||
|
@ -37,7 +34,6 @@ public class SysRegisterService {
|
||||||
* 注册
|
* 注册
|
||||||
*/
|
*/
|
||||||
public void register(RegisterBody registerBody) {
|
public void register(RegisterBody registerBody) {
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
|
||||||
String username = registerBody.getUsername();
|
String username = registerBody.getUsername();
|
||||||
String password = registerBody.getPassword();
|
String password = registerBody.getPassword();
|
||||||
// 校验用户类型是否存在
|
// 校验用户类型是否存在
|
||||||
|
@ -46,7 +42,7 @@ public class SysRegisterService {
|
||||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
if (captchaEnabled) {
|
if (captchaEnabled) {
|
||||||
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid(), request);
|
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
|
||||||
}
|
}
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserName(username);
|
sysUser.setUserName(username);
|
||||||
|
@ -70,9 +66,8 @@ public class SysRegisterService {
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @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 verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
|
||||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||||
RedisUtils.deleteObject(verifyKey);
|
RedisUtils.deleteObject(verifyKey);
|
||||||
|
|
Loading…
Reference in New Issue