feat: 新增sercurity的LogoutSuccessHandler的实现类
This commit is contained in:
parent
47409787a4
commit
4d57b45a02
@ -0,0 +1,38 @@
|
|||||||
|
package com.cnbm.admin.handler;
|
||||||
|
|
||||||
|
import com.cnbm.admin.entity.LoginUser;
|
||||||
|
import com.cnbm.admin.utils.ResponseResult;
|
||||||
|
import com.cnbm.admin.utils.WebUtils;
|
||||||
|
import com.cnbm.common.utils.JsonUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weihongyang
|
||||||
|
* @Date 2022/6/23 10:44 AM
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
|
ResponseResult result = new ResponseResult(HttpStatus.OK.value(),"退出成功");
|
||||||
|
String json = JsonUtils.toJsonString(result);
|
||||||
|
WebUtils.renderString(response,json);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user