|
@@ -1,23 +1,20 @@
|
|
|
package com.ruoyi.framework.shiro.web.filter;
|
|
|
|
|
|
-import java.io.Serializable;
|
|
|
-import java.util.Deque;
|
|
|
import javax.servlet.ServletRequest;
|
|
|
import javax.servlet.ServletResponse;
|
|
|
-import org.apache.shiro.cache.Cache;
|
|
|
-import org.apache.shiro.cache.CacheManager;
|
|
|
import org.apache.shiro.session.SessionException;
|
|
|
import org.apache.shiro.subject.Subject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
-import com.ruoyi.common.constant.ShiroConstants;
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
import com.ruoyi.framework.manager.AsyncManager;
|
|
|
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
|
|
import com.ruoyi.framework.util.ShiroUtils;
|
|
|
import com.ruoyi.system.domain.SysUser;
|
|
|
+import com.ruoyi.system.service.ISysUserOnlineService;
|
|
|
|
|
|
/**
|
|
|
* 退出过滤器
|
|
@@ -33,8 +30,6 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
|
|
|
*/
|
|
|
private String loginUrl;
|
|
|
|
|
|
- private Cache<String, Deque<Serializable>> cache;
|
|
|
-
|
|
|
public String getLoginUrl()
|
|
|
{
|
|
|
return loginUrl;
|
|
@@ -61,7 +56,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
|
|
|
// 记录用户退出日志
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success")));
|
|
|
// 清理缓存
|
|
|
- cache.remove(loginName);
|
|
|
+ SpringUtils.getBean(ISysUserOnlineService.class).removeUserCache(loginName, ShiroUtils.getSessionId());
|
|
|
}
|
|
|
// 退出登录
|
|
|
subject.logout();
|
|
@@ -92,11 +87,4 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
|
|
|
}
|
|
|
return super.getRedirectUrl(request, response, subject);
|
|
|
}
|
|
|
-
|
|
|
- // 设置Cache的key的前缀
|
|
|
- public void setCacheManager(CacheManager cacheManager)
|
|
|
- {
|
|
|
- // 必须和ehcache缓存配置中的缓存name一致
|
|
|
- this.cache = cacheManager.getCache(ShiroConstants.SYS_USERCACHE);
|
|
|
- }
|
|
|
}
|