Commit ee7a240c by cjh

修改后台同时请求token挤掉线问题

parent edddf672
...@@ -27,7 +27,11 @@ public class NoUiRequest { ...@@ -27,7 +27,11 @@ public class NoUiRequest {
String tokenId = request.getHeader("token"); String tokenId = request.getHeader("token");
String userId = request.getHeader("userId"); String userId = request.getHeader("userId");
String terminalType = request.getHeader("terminalType"); String terminalType = request.getHeader("terminalType");
if(tokenId.startsWith(Constants.BACKGROUND_FLAG)){
this.token = tokenId.substring(Constants.BACKGROUND_FLAG.length());
}else{
this.token = tokenId; this.token = tokenId;
}
this.userId = userId; this.userId = userId;
this.terminalType = terminalType; this.terminalType = terminalType;
this.mappingUrl = mappingUrl; this.mappingUrl = mappingUrl;
......
...@@ -14,4 +14,6 @@ public class Constants { ...@@ -14,4 +14,6 @@ public class Constants {
public final static String MAPPING_PRE = "_"; public final static String MAPPING_PRE = "_";
public final static String SESSION = "session"; public final static String SESSION = "session";
public final static String BACKGROUND_FLAG = "BackGroundRequest-";
} }
...@@ -48,7 +48,8 @@ public class NoUiContextManager { ...@@ -48,7 +48,8 @@ public class NoUiContextManager {
Class<?> clazz = Class.forName("org.sss.module." + dbType + ".ModuleSessionImpl"); Class<?> clazz = Class.forName("org.sss.module." + dbType + ".ModuleSessionImpl");
session = (IModuleSession) ConstructorUtils.invokeConstructor(clazz, new Object[] { noUiContext }); session = (IModuleSession) ConstructorUtils.invokeConstructor(clazz, new Object[] { noUiContext });
} catch (Exception e) { } catch (Exception e) {
throw new NoUiException("Constructs NoUiContext error"); log.error("Constructs NoUiContext error",e);
throw new NoUiException("Constructs NoUiContext error",e);
} }
noUiContext.setGui(new NoUiPresentation(noUiContext, noUiRequest)); noUiContext.setGui(new NoUiPresentation(noUiContext, noUiRequest));
noUiContext.setSession(session); noUiContext.setSession(session);
......
...@@ -60,8 +60,8 @@ public class TokenInterceptor implements HandlerInterceptor { ...@@ -60,8 +60,8 @@ public class TokenInterceptor implements HandlerInterceptor {
responseMessage(response, response.getWriter(), rt); responseMessage(response, response.getWriter(), rt);
return false; return false;
} }
//验证token是否一致 //验证token是否一致 如果为后台直接调用交易,则直接跳过token验证
if(!token.equals(redisLoginInfo.getToken())){ if( !token.startsWith(Constants.BACKGROUND_FLAG) && !token.equals(redisLoginInfo.getToken())){
Result rt = new Result(ErrorCodes.LOGIN_TOKEN_CHECKERROR, "token失效,该用户被强迫下线", null); Result rt = new Result(ErrorCodes.LOGIN_TOKEN_CHECKERROR, "token失效,该用户被强迫下线", null);
responseMessage(response, response.getWriter(), rt); responseMessage(response, response.getWriter(), rt);
return false; return false;
......
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