39 lines
1.4 KiB
Java
39 lines
1.4 KiB
Java
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);
|
|
}
|
|
}
|