From ff3ebae026537f151d3fd604048597b7738a925a Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Fri, 06 Mar 2026 08:47:52 +0800
Subject: [PATCH] 1. 大文件上传并解压接口业务优化 2. 优化精细化巡检分组权限管理 3. 优化点云文件权限管理 4. 上传到服务器点云文件
---
ard-framework/src/main/java/com/ard/framework/security/handle/CustomAuthenticationSuccessHandler.java | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 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 4ae53bf..1efc113 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,20 +1,46 @@
package com.ard.framework.security.handle;
+import com.ard.common.constant.CacheConstants;
+import com.ard.common.constant.Constants;
+import com.ard.common.core.domain.model.LoginUser;
import com.ard.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
@Component
public class CustomAuthenticationSuccessHandler {
+ @Value("${token.soloLogin}")
+ private boolean soloLogin;
+
@Autowired
private RedisCache redisCache;
- public void onAuthenticationSuccess(Long userId) {
+ @Autowired
+ private ApplicationEventPublisher publisher;
+
+ public void onAuthenticationSuccess(Authentication authentication) {
+ // 允许多端登录,直接放行
+ if (soloLogin) {
+ return;
+ }
// 检查 Redis 中是否已有该用户登录
- String key = "login_userid:" + userId;
+ LoginUser loginUser = (LoginUser) authentication.getPrincipal();
+ Long userId = loginUser.getUser().getUserId();
+
+ String key = CacheConstants.LOGIN_USERID_KEY + userId;
if (redisCache.hasKey(key)) {
throw new RuntimeException("用户已登录,请勿重复登录");
}
+ // 登录成功事件推送
+ if (authentication != null && authentication.isAuthenticated()) {
+ publisher.publishEvent(new AuthenticationSuccessEvent(authentication));
+ }
}
+
}
--
Gitblit v1.9.3