mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
reLoginUrl
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Controller
|
||||
@@ -37,19 +38,35 @@ public class LogoutEndpoint {
|
||||
|
||||
private static Logger _logger = LoggerFactory.getLogger(LogoutEndpoint.class);
|
||||
|
||||
public static final String RE_LOGIN_URL = "reLoginUrl";
|
||||
|
||||
@Autowired
|
||||
@Qualifier("authenticationRealm")
|
||||
AbstractAuthenticationRealm authenticationRealm;
|
||||
|
||||
@RequestMapping(value={"/logout"})
|
||||
public ModelAndView logout(HttpServletRequest request, HttpServletResponse response){
|
||||
public ModelAndView logout( HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@RequestParam(value=RE_LOGIN_URL,required=false) String reLoginUrl){
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
authenticationRealm.logout(response);
|
||||
SavedRequest firstSavedRequest = (SavedRequest)WebContext.getAttribute(WebConstants.FIRST_SAVED_REQUEST_PARAMETER);
|
||||
String reLoginUrl=WebContext.getHttpContextPath()+"/login";
|
||||
|
||||
if(reLoginUrl==null ||reLoginUrl.equals("")) {
|
||||
reLoginUrl="/login";
|
||||
}
|
||||
|
||||
if(firstSavedRequest!=null){
|
||||
reLoginUrl= firstSavedRequest.getRedirectUrl();
|
||||
}
|
||||
|
||||
if(reLoginUrl!=null && !reLoginUrl.toLowerCase().startsWith("http")) {
|
||||
if(reLoginUrl.startsWith("/")) {
|
||||
reLoginUrl=request.getContextPath()+reLoginUrl;
|
||||
}else {
|
||||
reLoginUrl=request.getContextPath()+"/"+reLoginUrl;
|
||||
}
|
||||
}
|
||||
_logger.debug("re Login URL : "+ reLoginUrl);
|
||||
modelAndView.addObject("reloginUrl",reLoginUrl);
|
||||
request.getSession().invalidate();
|
||||
|
||||
@@ -95,9 +95,9 @@ public class LogoutEndpoint {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
authenticationRealm.logout(response);
|
||||
|
||||
if(reLoginUrl==null){
|
||||
if(reLoginUrl==null ||reLoginUrl.equals("")){
|
||||
SavedRequest firstSavedRequest = (SavedRequest)WebContext.getAttribute(WebConstants.FIRST_SAVED_REQUEST_PARAMETER);
|
||||
reLoginUrl=WebContext.getHttpContextPath()+"/login";
|
||||
reLoginUrl="/login";
|
||||
if(firstSavedRequest!=null){
|
||||
reLoginUrl= firstSavedRequest.getRedirectUrl();
|
||||
WebContext.removeAttribute(WebConstants.FIRST_SAVED_REQUEST_PARAMETER);
|
||||
@@ -106,7 +106,11 @@ public class LogoutEndpoint {
|
||||
|
||||
//not start with http or https
|
||||
if(reLoginUrl!=null && !reLoginUrl.toLowerCase().startsWith("http")) {
|
||||
reLoginUrl=WebContext.getHttpContextPath()+"/"+reLoginUrl;
|
||||
if(reLoginUrl.startsWith("/")) {
|
||||
reLoginUrl=request.getContextPath()+reLoginUrl;
|
||||
}else {
|
||||
reLoginUrl=request.getContextPath()+"/"+reLoginUrl;
|
||||
}
|
||||
}
|
||||
|
||||
_logger.debug("re Login URL : "+ reLoginUrl);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link type="text/css" rel="stylesheet" href="<@base />/static/css/base.css"/>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="<@base />/static/images/favicon.ico"/>
|
||||
|
||||
<base href="<@basePath/>"/>
|
||||
<base href="<@base />"/>
|
||||
<script src ="<@base />/static/jquery/jquery-3.5.0.min.js" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="<@base />/static/jquery/encrypt/jsbn.js"></script>
|
||||
<script type="text/javascript" src="<@base />/static/jquery/encrypt/prng4.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user