如果是在个性化用户类型的登录界面,登录的系统,则在退出时返回对应用户类型的登录界面。

This commit is contained in:
thinkgem
2020-09-20 09:41:54 +08:00
parent 055d791c44
commit f3bb96d719

View File

@@ -38,16 +38,17 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
try {
Object principal = subject.getPrincipal();
if (principal != null){
// // 记录用户退出日志(@Deprecated v4.0.5支持setAuthorizingRealm之后版本可删除此if子句
// if (authorizingRealm == null){
// LogUtils.saveLog(UserUtils.getUser(), ServletUtils.getRequest(),
// "系统退出", Log.TYPE_LOGIN_LOGOUT);
// }
// else{
// 退出成功之前初始化授权信息并处理登录后的操作
authorizingRealm.onLogoutSuccess((LoginInfo)subject.getPrincipal(),
(HttpServletRequest)request);
// }
LoginInfo loginInfo = (LoginInfo)principal;
// 退出成功之前调用退出事件,方便记录日志等相关销毁工作
authorizingRealm.onLogoutSuccess(loginInfo, (HttpServletRequest)request);
// 设定了用户类型的登录页面,则退出到对应用户类型的登录页面
String userType = loginInfo.getParam("userType");
if(StringUtils.isNotBlank(userType)){
redirectUrl += StringUtils.contains(redirectUrl, "?") ? "&" : "?";
redirectUrl += "param_userType=" + userType;
}
}
// 退出登录
subject.logout();