Quellcode durchsuchen

Merge remote-tracking branch 'origin/branch-nt-1.0.1' into branch-nt-1.0.1

sakuya vor 3 Jahren
Ursprung
Commit
d28bf76587

+ 17 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/UserController.java

@@ -30,6 +30,7 @@ import me.zhengjie.application.admin.service.dto.RoleSmallDto;
 import me.zhengjie.application.admin.service.dto.UserDto;
 import me.zhengjie.application.admin.service.dto.UserQueryCriteria;
 import me.zhengjie.base.AppBaseResponse;
+import me.zhengjie.base.ResultCode;
 import me.zhengjie.base.util.ApplicationContextUtil;
 import me.zhengjie.base.util.BeanCopyUtils;
 import me.zhengjie.base.util.FileUploadUtil;
@@ -48,6 +49,9 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.authentication.AnonymousAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
@@ -306,4 +310,17 @@ public class UserController {
     public AppBaseResponse getAuthStatus(){
         return userService.getAuthStatus();
     }
+    /**
+     * 校验登录状态
+     * @return
+     */
+    @AnonymousPostMapping("/checkAuth")
+    public AppBaseResponse<?> checkAuth(){
+         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        if (authentication == null || authentication instanceof AnonymousAuthenticationToken) {
+         return	AppBaseResponse.error(ResultCode.PERMISSION_TOKEN_INVALID);
+        }
+        return AppBaseResponse.success();
+    }
+    
 }

+ 4 - 0
eladmin-system/src/main/java/me/zhengjie/base/websocket/PcOnlineUserService.java

@@ -33,6 +33,10 @@ public class PcOnlineUserService extends OnlineUserService {
 			userClient.forEach((uuid, socketIOClient) -> {
 				socketIOClient.sendEvent("logoutEvent", "close");
 			});
+			userClient.forEach((uuid, socketIOClient) -> {
+				socketIOClient.disconnect();
+			});
 		}
+
 	}
 }

+ 1 - 1
eladmin-system/src/main/resources/config/application.yml

@@ -3,7 +3,7 @@ spring:
   freemarker:
     check-template-location: false
   profiles:
-    active: prod
+    active: nt-test
   jackson:
     time-zone: GMT+8
   data: