Esempio n. 1
0
        public JsonResult checkOutsideLogin(string name, string pwd, string type = "")
        {
            var result   = "error";
            var username = "";
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            paramDictionary.Add("userNo", name.Trim());
            paramDictionary.Add("password", pwd.Trim());

            AuthorizationParams ap = new AuthorizationParams();

            ap.METHOD     = "wavenet.fxsw.engin.login";
            ap.TIMESTAMP  = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
            ap.URL        = ConfigurationManager.AppSettings["apiUrl"].ToString();
            ap.APP_KEY    = CookieHelper.GetCookie(Request).app_key;
            ap.APP_SECRET = CookieHelper.GetCookie(Request).app_secret;
            ap.SESSION    = CookieHelper.GetCookie(Request).app_session;
            paramDictionary.Add("type", type);//unit  person

            var authorization = AuthorizationUtils.Authorization(ap, paramDictionary);

            if (authorization.Contains("账号或密码错误"))
            {
                result = "error";
            }
            else
            {
                EnginSignInResponse signInResponse = JsonToObject <EnginSignInResponse>(authorization);
                if (signInResponse != null && signInResponse.enginLoginResponse != null && signInResponse.enginLoginResponse.result == "True")
                {
                    result          = "sucess";
                    username        = signInResponse.enginLoginResponse.name;
                    Session["name"] = username;
                    CookieHelper.WriteCookie("app_key", CookieHelper.GetCookie(Request).app_key, 0);
                    CookieHelper.WriteCookie("app_secret", CookieHelper.GetCookie(Request).app_secret, 0);
                    CookieHelper.WriteCookie("app_session", CookieHelper.GetCookie(Request).app_session, 0);
                    CookieHelper.WriteCookie("unit_name", username, 0);
                    CookieHelper.WriteCookie("token", name, 0);
                    CookieHelper.WriteCookie("type", type, 0);
                }
            }
            return(Json(new { name = name, result = result }));
        }