|
|
@@ -11,6 +11,8 @@ import javax.core.common.utils.RandomNumUtils;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
@@ -29,6 +31,7 @@ import cn.vbdsm.passport.service.IAuthService;
|
|
|
@RequestMapping("/web")
|
|
|
public class AuthAction extends BaseAction {
|
|
|
|
|
|
+ private static final Log log = LogFactory.getLog(AuthAction.class);
|
|
|
@Resource
|
|
|
private IAuthService authService;
|
|
|
|
|
|
@@ -79,8 +82,17 @@ public class AuthAction extends BaseAction {
|
|
|
public ModelAndView loginForDemo(HttpServletRequest request, HttpServletResponse response) {
|
|
|
String domain = getDomain(request);
|
|
|
String ip = getIpAddr(request);
|
|
|
+ Long localSiteId = null;
|
|
|
+ String siteIdStr = request.getHeader("Site-Id");
|
|
|
+ if(!siteIdStr.isEmpty()){
|
|
|
+ try{
|
|
|
+ localSiteId = Long.parseLong(siteIdStr);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("Site-Id is not number");
|
|
|
+ }
|
|
|
+ }
|
|
|
String agent = request.getHeader("User-Agent").toLowerCase();
|
|
|
- ResultMsg<JSONObject> result = authService.login("zh_CN", domain, "demo", "demo", null, null, ip, agent);
|
|
|
+ ResultMsg<JSONObject> result = authService.login("zh_CN", domain, "demo", "demo", null, null, ip, agent,localSiteId);
|
|
|
if (SystemConstant.RESULT_STATUS_SUCCESS == result.getStatus()) {
|
|
|
writeCookie(request, response, result.getData());
|
|
|
}
|
|
|
@@ -101,9 +113,18 @@ public class AuthAction extends BaseAction {
|
|
|
, @RequestParam(value = "authCode", required = false) String authCode) {
|
|
|
String domain = getDomain(request);
|
|
|
String ip = getIpAddr(request);
|
|
|
+ Long localSiteId = null;
|
|
|
+ String siteIdStr = request.getHeader("Site-Id");
|
|
|
+ if(!siteIdStr.isEmpty()){
|
|
|
+ try{
|
|
|
+ localSiteId = Long.parseLong(siteIdStr);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("Site-Id is not number");
|
|
|
+ }
|
|
|
+ }
|
|
|
String agent = request.getHeader("User-Agent").toLowerCase();
|
|
|
Object session_code = request.getSession().getAttribute(SystemConstant.SYSTEM_LOGIN_AUTHCODE);
|
|
|
- ResultMsg<JSONObject> result = authService.login("zh_CN", domain, loginName, loginPass, authCode, session_code, ip, agent);
|
|
|
+ ResultMsg<JSONObject> result = authService.login("zh_CN", domain, loginName, loginPass, authCode, session_code, ip, agent,localSiteId);
|
|
|
if (SystemConstant.RESULT_STATUS_SUCCESS == result.getStatus()) {
|
|
|
request.getSession().removeAttribute(SystemConstant.SYSTEM_LOGIN_AUTHCODE);
|
|
|
writeCookie(request, response, result.getData());
|
|
|
@@ -137,4 +158,18 @@ public class AuthAction extends BaseAction {
|
|
|
CookiesUtil.write(domain, SystemConstant.SYSTEM_LOGIN_COOKIE, authService.genUserkey(json), response, request);
|
|
|
}
|
|
|
|
|
|
+// private String getCookieDomain(HttpServletRequest request) {
|
|
|
+// String domain = request.getHeader("Accept");
|
|
|
+// log.info("domain1:" + domain);
|
|
|
+// if (domain == null || domain.trim().isEmpty()) {
|
|
|
+// log.info("domain2:" + domain);
|
|
|
+// domain = getDomain(request);
|
|
|
+// }
|
|
|
+// if (domain == null || domain.trim().isEmpty()) {
|
|
|
+// log.info("domain3:" + domain);
|
|
|
+// domain = "vbdsm.com";
|
|
|
+// }
|
|
|
+// return domain;
|
|
|
+// }
|
|
|
+
|
|
|
}
|