示例#1
0
        public object Login(string account, string password)
        {
            try
            {
                var re = UserServer.Login(account, password);

                //如果登陆成功  设置session
                if (re != "login successful")
                {
                    return new { msg = re }
                }
                ;

                var user = UserServer.GetUser(account);
                HttpContext.Session.SetString("user_Account", account);
                HttpContext.Session.SetString("user_Password", user.password);
                HttpContext.Session.SetString("user_Type", user.userType);
                HttpContext.Session.SetString("user_Province", user.province);
                HttpContext.Session.SetString("user_phoneNumber", user.phoneNumber);

                return(new { msg = re });
            }
            catch (Exception e)
            {
                return(new { msg = e.Message });
            }
        }
示例#2
0
        public object Login([FromBody] LoginModel lm)
        {
            try
            {
//                var addr = Server.GetUserIp(Request.HttpContext);
//
//                if (Server.IpHandle(addr) == 0)
//                {
//                    return new[] { "your ip can't using our api , please contact administrator" };
//                }


                var verCode = HttpContext.Session.GetString("user_verCode");

                if (verCode == null)
                {
                    return(new
                    {
                        result = 401,
                        msg = "verCode session is null"
                    });
                }


                if (verCode != lm.VerCode)
                {
                    return(new
                    {
                        result = 401,
                        msg = "wrong verCode",
                        veC = verCode,
                        subVec = lm.VerCode
                    });
                }

                var re = UserServer.Login(lm);

                if (re.result == 200)
                {
                    HttpContext.Session.Remove("user_verCode");
                    HttpContext.Session.SetString("user_account", lm.Account);
                }

                return(re);
            }
            catch (Exception e)
            {
                return(new
                {
                    result = e.HResult,
                    msg = e.Message
                });
            }
        }
示例#3
0
        public object Login(string account, string password)
        {
            try
            {
                var addr = Server.GetUserIp(Request.HttpContext);
                if (Server.IPHandle(addr) == 0)
                {
                    return(new { msg = "your ip can't using our api , please contact administrator" });
                }

                var re = UserServer.Login(account, password);

                return(new { msg = re });
            }
            catch (Exception e)
            {
                return(new { msg = e.Message });
            }
        }
示例#4
0
        public object Login([FromBody] LoginModel um)
        {
            try
            {
                var re = UserServer.Login(um.Account, um.Password);

                //如果登陆成功  设置session
                var user = UserServer.GetUser(um.Account);
                HttpContext.Session.SetString("user_Account", um.Account);
                HttpContext.Session.SetString("user_Password", user.password);
                HttpContext.Session.SetString("user_Type", user.userType);
                HttpContext.Session.SetString("user_Province", user.province);
                HttpContext.Session.SetString("user_phoneNumber", user.phoneNumber);

                return(new { msg = re });
            }
            catch (Exception e)
            {
                return(new { msg = e.Message });
            }
        }