Ajax 로그 인 ofbiz

public static String login(HttpServletRequest request, HttpServletResponse response) {
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    String username=request.getParameter("loginPhone");
    String pwd=request.getParameter("pwd");
    String rember=request.getParameter("rember");
    HttpSession session=request.getSession();

    //  
    String visitId = VisitHandler.getVisitId(session);
    try {
        Map<String,Object>  result = dispatcher.runSync("userLogin", UtilMisc.toMap(
                "login.username", username, "login.password", pwd,
                "visitId", visitId, "locale",
                UtilHttp.getLocale(request)));
        if(result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS)){
            GenericValue userLogin = (GenericValue) result.get("userLogin");
            Map<String, Object> userLoginSession = checkMap(result.get("userLoginSession"), String.class, Object.class);
            LoginWorker.doMainLogin(request, response, userLogin, userLoginSession);
            //  
            request.setAttribute("errorCode","success");
            if(UtilValidate.isNotEmpty(rember) && rember.equals("1")){
                //    
                LoginWorker.autoLoginSet(request,response);
            }
        }else{
            request.setAttribute("errorCode","error");
        }
    } catch (GenericServiceException e) {
        e.printStackTrace();
        request.setAttribute("errorCode","error");
    }
    return "success";
}

좋은 웹페이지 즐겨찾기