Commit 42525f86 by fukai

支持设置token进入session

parent b7129f90
...@@ -92,6 +92,8 @@ public class LoginController { ...@@ -92,6 +92,8 @@ public class LoginController {
RedisLoginInfo redisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), sysmodBytes, noUiRequest.getTerminalType()); RedisLoginInfo redisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), sysmodBytes, noUiRequest.getTerminalType());
redisLoginInfo.setUserInr((String)inridf.getValue()); //设置当前用户主键 redisLoginInfo.setUserInr((String)inridf.getValue()); //设置当前用户主键
request.getSession().setAttribute("token",token);
NoUiUtils.logout(userId,"*"); //清理可能存在的历史缓存 NoUiUtils.logout(userId,"*"); //清理可能存在的历史缓存
RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo); RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo);
...@@ -154,6 +156,7 @@ public class LoginController { ...@@ -154,6 +156,7 @@ public class LoginController {
public Object logout(HttpServletRequest request, HttpSession session) { public Object logout(HttpServletRequest request, HttpSession session) {
try { try {
request.getSession().removeAttribute("toekn");
NoUiRequest noUiRequest = new NoUiRequest(request, "", null); NoUiRequest noUiRequest = new NoUiRequest(request, "", null);
NoUiUtils.logout(noUiRequest.getUserId(),"*"); //清理可能存在的历史缓存 NoUiUtils.logout(noUiRequest.getUserId(),"*"); //清理可能存在的历史缓存
return ResultUtil.result(ErrorCodes.SUCCESS,"退出成功",null); return ResultUtil.result(ErrorCodes.SUCCESS,"退出成功",null);
......
...@@ -31,6 +31,12 @@ public class ResourceAccessFilter implements Filter { ...@@ -31,6 +31,12 @@ public class ResourceAccessFilter implements Filter {
try { try {
HttpServletRequest request = (HttpServletRequest) req; HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res; HttpServletResponse response = (HttpServletResponse) res;
if(request.getSession().getAttribute("token")== null)
{
response.setStatus(403);
forbidden(request, response);
return;
}
String uri = request.getRequestURI(); String uri = request.getRequestURI();
String pdfres; String pdfres;
if ((pdfres=needPdfsFilter(uri))!=null) { if ((pdfres=needPdfsFilter(uri))!=null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment