From 38f9471ecf47b7c15b352113bc0f5a2ec1e64e7b Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期二, 16 七月 2024 09:24:13 +0800 Subject: [PATCH] 登录返回vo修改,个人中心接口,用户列表权限验证 --- src/main/java/com/ycl/jxkg/config/spring/security/RestLogoutSuccessHandler.java | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/config/spring/security/RestLogoutSuccessHandler.java b/src/main/java/com/ycl/jxkg/config/spring/security/RestLogoutSuccessHandler.java index 9a35774..5517844 100644 --- a/src/main/java/com/ycl/jxkg/config/spring/security/RestLogoutSuccessHandler.java +++ b/src/main/java/com/ycl/jxkg/config/spring/security/RestLogoutSuccessHandler.java @@ -1,13 +1,16 @@ package com.ycl.jxkg.config.spring.security; import com.ycl.jxkg.base.SystemCode; +import com.ycl.jxkg.constants.CaffeineConstant; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.domain.entity.UserEventLog; import com.ycl.jxkg.event.UserEvent; import com.ycl.jxkg.service.UserService; +import com.ycl.jxkg.utils.CaffeineUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; import org.springframework.stereotype.Component; @@ -27,6 +30,7 @@ private final ApplicationEventPublisher eventPublisher; private final UserService userService; + private final CaffeineUtil caffeineUtil; /** * Instantiates a new Rest logout success handler. @@ -35,15 +39,19 @@ * @param userService the user service */ @Autowired - public RestLogoutSuccessHandler(ApplicationEventPublisher eventPublisher, UserService userService) { + public RestLogoutSuccessHandler(ApplicationEventPublisher eventPublisher, UserService userService, CaffeineUtil caffeineUtil) { this.eventPublisher = eventPublisher; this.userService = userService; + this.caffeineUtil = caffeineUtil; } @Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { org.springframework.security.core.userdetails.User springUser = (org.springframework.security.core.userdetails.User) authentication.getPrincipal(); if (null != springUser) { + // 娓呴櫎鐢ㄦ埛鍚嶅拰sessionId涔嬮棿鐨勭粦瀹� + caffeineUtil.remove(CaffeineConstant.AUTH, springUser.getUsername()); + SecurityContextHolder.clearContext(); User user = userService.getUserByUserName(springUser.getUsername()); UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); userEventLog.setContent(user.getUserName() + " 鐧诲嚭浜嗗涔嬫�濆紑婧愯�冭瘯绯荤粺"); -- Gitblit v1.8.0