diff --git a/auth/src/main/java/cn/fateverse/auth/service/impl/LoginServiceImpl.java b/auth/src/main/java/cn/fateverse/auth/service/impl/LoginServiceImpl.java index f71b489..bfd8e1c 100644 --- a/auth/src/main/java/cn/fateverse/auth/service/impl/LoginServiceImpl.java +++ b/auth/src/main/java/cn/fateverse/auth/service/impl/LoginServiceImpl.java @@ -85,18 +85,18 @@ public class LoginServiceImpl implements LoginService { @Override public String login(LoginBody login) { log.info("用户:{},于:{}登录系统", login.getUsername(), DateUtil.format(new Date(), DateConstants.YYYY_MM_DD_HH_MM_SS)); -// String uuid = CacheConstants.CAPTCHA_CODE_KEY + login.getUuid(); -// String code = String.valueOf(redisTemplate.opsForValue().get(uuid)); -// if (null == code) { -// publishEvent(login.getUsername(), "验证码已过期!", Boolean.FALSE, null); -// throw new CustomException("验证码已过期!"); -// } -// if (!code.equals(login.getCode())) { -// publishEvent(login.getUsername(), "验证码错误!", Boolean.FALSE, null); -// throw new CustomException("验证码错误!"); -// } -// redisTemplate.delete(uuid); - //用户验证 + String uuid = CacheConstants.CAPTCHA_CODE_KEY + login.getUuid(); + String code = String.valueOf(redisTemplate.opsForValue().get(uuid)); + if (null == code) { + publishEvent(login.getUsername(), "验证码已过期!", Boolean.FALSE, null); + throw new CustomException("验证码已过期!"); + } + if (!code.equals(login.getCode())) { + publishEvent(login.getUsername(), "验证码错误!", Boolean.FALSE, null); + throw new CustomException("验证码错误!"); + } + redisTemplate.delete(uuid); + //用户验证 Authentication authentication = null; try { // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername diff --git a/common/common-log/src/main/java/cn/fateverse/common/log/aspect/LogAspect.java b/common/common-log/src/main/java/cn/fateverse/common/log/aspect/LogAspect.java index 8986fd8..cd1a62d 100644 --- a/common/common-log/src/main/java/cn/fateverse/common/log/aspect/LogAspect.java +++ b/common/common-log/src/main/java/cn/fateverse/common/log/aspect/LogAspect.java @@ -47,7 +47,7 @@ public class LogAspect { @Around("@within(log) || @annotation(log)") - public Object before(ProceedingJoinPoint point, Log log) throws Throwable { + public Object around(ProceedingJoinPoint point, Log log) throws Throwable { long startTime = System.currentTimeMillis(); try { Object proceed = point.proceed(point.getArgs()); diff --git a/notice/notice-biz/src/main/java/cn/fateverse/notice/config/RedisTemplateConfig.java b/notice/notice-biz/src/main/java/cn/fateverse/notice/config/RedisTemplateConfig.java deleted file mode 100644 index 4656a82..0000000 --- a/notice/notice-biz/src/main/java/cn/fateverse/notice/config/RedisTemplateConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.fateverse.notice.config; - -import cn.fateverse.notice.entity.UserInfo; -import org.redisson.spring.data.connection.RedissonConnectionFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.StringRedisSerializer; - -/** - * @author Clay - * @date 2023-10-15 - */ -//@Configuration -public class RedisTemplateConfig { - - - @Bean("noticeRedisTemplate") - public RedisTemplate noticeRedisTemplate(RedissonConnectionFactory redissonConnectionFactory) { - RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(redissonConnectionFactory); - //设置key序列化方式string - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setHashKeySerializer(new StringRedisSerializer()); - redisTemplate.afterPropertiesSet(); - return redisTemplate; - } - - - -}