From 04fc08896a8092ac8000e9d06528748653bf70a3 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Wed, 17 Dec 2025 14:53:06 +0800
Subject: [PATCH] 优化
---
ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java b/ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java
index 5744902..a660bda 100644
--- a/ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java
+++ b/ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java
@@ -1,19 +1,28 @@
package com.ard.framework.security.handle;
+import com.ard.common.constant.CacheConstants;
import com.ard.common.constant.Constants;
import com.ard.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class CustomAuthenticationSuccessHandler {
+ @Value("${token.soloLogin}")
+ private boolean soloLogin;
+
@Autowired
private RedisCache redisCache;
public void onAuthenticationSuccess(Long userId) {
+ // 允许多端登录,直接放行
+ if (soloLogin) {
+ return;
+ }
// 检查 Redis 中是否已有该用户登录
- String key = Constants.LOGIN_USERID_KEY + userId;
+ String key = CacheConstants.LOGIN_USERID_KEY + userId;
if (redisCache.hasKey(key)) {
throw new RuntimeException("用户已登录,请勿重复登录");
}
--
Gitblit v1.9.3