Example #1
0
        public ActionResult Authenticate(string accountNo, string passwordE2ee)
        {
            Response.Buffer          = true;
            Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            Response.CacheControl    = "no-cache";
            //Response.Expires = 0;
            //Response.CacheControl = "no-cache,no-store";
            //Response.AddHeader("Pragma", "No-Cache");
            JObject json = new JObject();

            Presession pression = null;

            if (Session["Presession"] != null)
            {
                pression = (Presession)Session["Presession"];
            }
            else
            {
                json.Add("code", (int)MsgCode.SESSION_EXPIRED_ERR);
                json.Add("msg", ReturnMsg.msgList[(int)MsgCode.SESSION_EXPIRED_ERR]);
                return(Content(json.ToString()));
            }

            ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            logger.Info("Login: Acc=" + accountNo + "   PassE2EE=" + passwordE2ee);

            try
            {
                string deviceId = Session["openid"].ToString();
                string language = Session["language"].ToString();
                string result   = authMgr.getAuth(deviceId, language, accountNo, passwordE2ee, pression.sessionID);

                STReturn ret = Global.chkJsonStats(result);
                if (int.Parse(ret.retCode) == (int)MsgCode.OPR_SUCC)
                {
                    UserInfo user = new UserInfo();
                    user.accountNo    = accountNo;
                    user.encryptedPIN = passwordE2ee;
                    user.sessionID    = pression.sessionID;
                    user.randomNo     = pression.randomNo;
                    user.publicKey    = pression.publicKey;


                    JObject authResult = JObject.Parse(result);
                    user.accountType = authResult["accountType"].ToString();

                    //Session.Abandon();
                    //Session["openid"] = deviceId;
                    //Session["language"] = language;
                    Session["User"] = user;

                    // add trade limit.2017-6-19
                    string tradeEnable = ConfigurationManager.AppSettings["tradeEnable"];
                    if (tradeEnable != "1")
                    {
                        tradeEnable = "0";
                    }
                    JObject jsonAdd = JObject.Parse(result);
                    jsonAdd.Add("tradeEnable", tradeEnable);
                    result = jsonAdd.ToString();
                    {
                        string resultAccess = setMgr.getProductaccess(deviceId, user.accountNo, user.sessionID, language);
                    }

                    return(Content(result));
                }
                else
                {
                    json.Add("code", ret.retCode);
                    json.Add("msg", ret.retMsg);
                    //json.Add("sessionID", pression.sessionID);//test
                    //json.Add("deviceId", deviceId);//test
                    return(Content(json.ToString()));
                }
            }
            catch (WeChatException ex)
            {
                json.RemoveAll();
                json.Add("code", ex.WeChatErrorCode);
                json.Add("msg", ex.WeChatErrorMessage);
                //json.Add("sessionID", "---");//test
                return(Content(json.ToString()));
            }
            catch (Exception)
            {
                json.RemoveAll();
                json.Add("code", (int)MsgCode.SYSTEM_ERR);
                json.Add("msg", ReturnMsg.msgList[(int)MsgCode.SYSTEM_ERR]);
                return(Content(json.ToString()));
            }
        }