Commit add51102 by PWF-WK01\pengwufeng

登录缓存区域公司信息

parent 2ada3539
......@@ -15,6 +15,11 @@ public interface AuthcConstants {
public String CURRENTUSER = "currentUser";
/**
* 当前用户数据集
*/
public String CURRENTUSERDATAS = "currentUserDatas";
/**
* 当前用户名称
*/
public String USERNAME = "username";
......
......@@ -2,10 +2,13 @@ package com.beecode.inz.authentication.handler;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -31,6 +34,11 @@ import com.beecode.inz.authentication.util.LoginLogUtil;
@Component
public class RESTAppAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
/**
* 登录时区域公司的参数key
*/
private final static String REQUEST_CURRENTREGIONALCOMPANY_KEY = "currentRegionalCompany";
@Autowired
private TenantUserService tenantUserService;
@Autowired
......@@ -52,8 +60,13 @@ public class RESTAppAuthenticationSuccessHandler extends SimpleUrlAuthentication
request.getSession().setAttribute(AuthcConstants.USERID, tenantUser.getUserId());
request.getSession().setAttribute("mobile", true);
request.getSession().setMaxInactiveInterval(30*24*60*60);
//构建当前用户数据集
buildCurrentUserDatas(request);
loginLog.setTenantId(tenantUser.getTenantId());
loginLogService.insert(loginLog);
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
returnJson.put(AuthcConstants.USERID, tenantUser.getUserId());
returnJson.put(AuthcConstants.USERNAME, tenantUser.getUsername());
......@@ -68,9 +81,27 @@ public class RESTAppAuthenticationSuccessHandler extends SimpleUrlAuthentication
} finally {
}
}
/**
* 构造当前用户数据集
*/
private void buildCurrentUserDatas(HttpServletRequest request) {
HttpSession session = request.getSession();
//获取当前用户区域公司参数,存入当前用户数据集(session)
String currentRegionalCompany = obtainCurrentRegionalCompany(request);
Map<String, String > datas = new ConcurrentHashMap<>();
datas.put(REQUEST_CURRENTREGIONALCOMPANY_KEY, currentRegionalCompany);
//目前数据集只存了用户区域公司
session.setAttribute(AuthcConstants.CURRENTUSERDATAS, datas);
}
private String obtainCurrentRegionalCompany(HttpServletRequest request) {
return request.getParameter(REQUEST_CURRENTREGIONALCOMPANY_KEY);
}
public LoginLog getLoginLog(HttpServletRequest request){
LoginLog loginLog=new LoginLog();
String userAgent = request.getHeader(LoginLogConstants.USER_AGENT);
......
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