Ejemplo n.º 1
0
        public ActionResult Login(RequestData data)
        {
            LangHelper.Name = "zhcn";
            if (string.IsNullOrEmpty(data.Get("lang")) == false)
            {
                LangHelper.Name = data.Get("lang");
            }
            LangHelper.Instance.Read(base.Request, true);

            base.Response.ContentType = "text/plain";
            var userName       = data.Get("username");
            var password       = data.Get("password");
            var validateCode   = data.Get("validateCode");
            var saveCookieDays = data.GetInt("savedays");

            var msg = new { success = false, message = "用户名不存在!" };

            SqlModel model = SqlModel.SelectAll().From(DB.BASUSER).Where(BASUSER.USERNAME == userName);

            DataRowModel uModel = model.ExecToRowModel();

            if (uModel != null)
            {
                if (uModel[BASUSER.ISDISABLED].ToInt32() == 1)
                {
                    bool flag = CurrentUser.Login(userName, password);
                    if (flag == true)
                    {
                        msg            = new { success = true, message = "登录成功!" };
                        DataInitor.Log = new LogData();
                        base.AddLog(LogType.UserLogin, "用户登录成功");
                    }
                    else
                    {
                        msg = new { success = false, message = "用户名或密码输入错误!" };
                    }
                }
                else
                {
                    msg = new { success = false, message = "用户已经被禁用,请联系管理员!" };
                }
            }
            return(Json(msg));
        }