mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 09:28:49 +08:00
mgt logout invalidate http Session
This commit is contained in:
parent
91514cce7e
commit
f84e1d5607
@ -17,10 +17,14 @@
|
|||||||
|
|
||||||
package org.maxkey.web.contorller;
|
package org.maxkey.web.contorller;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.maxkey.authn.annotation.CurrentUser;
|
import org.maxkey.authn.annotation.CurrentUser;
|
||||||
import org.maxkey.authn.session.SessionManager;
|
import org.maxkey.authn.session.SessionManager;
|
||||||
import org.maxkey.entity.Message;
|
import org.maxkey.entity.Message;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@ -29,16 +33,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class LogoutEndpoint {
|
public class LogoutEndpoint {
|
||||||
|
private static Logger _logger = LoggerFactory.getLogger(LogoutEndpoint.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SessionManager sessionManager;
|
protected SessionManager sessionManager;
|
||||||
|
|
||||||
@RequestMapping(value={"/logout"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
@RequestMapping(value={"/logout"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
public ResponseEntity<?> logout(@CurrentUser UserInfo currentUser){
|
public ResponseEntity<?> logout(HttpServletRequest request,@CurrentUser UserInfo currentUser){
|
||||||
sessionManager.terminate(
|
sessionManager.terminate(
|
||||||
currentUser.getSessionId(),
|
currentUser.getSessionId(),
|
||||||
currentUser.getId(),
|
currentUser.getId(),
|
||||||
currentUser.getUsername());
|
currentUser.getUsername());
|
||||||
|
//invalidate http session
|
||||||
|
_logger.debug("/logout invalidate http Session id {}",request.getSession().getId());
|
||||||
|
request.getSession().invalidate();
|
||||||
return new Message<String>().buildResponse();
|
return new Message<String>().buildResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user