Example #1
0
        public JsonResult Login(FormCollection form)
        {
            string  account  = form["account"].ToString();
            string  password = form["password"].ToString();
            SysUser user     = new SysUser();

            user.LoginName = form["account"].ToString();
            var result = SysUserDao.Instance.GetSysUsers(user).FirstOrDefault();

            if (result == null)
            {
                return(Json(new { status = "0", message = "用户名不存在" }));
            }
            if (result.Password != Utility.MD5Helper.MD5(password))
            {
                return(Json(new { status = "0", message = "密码不对" }));
            }
            //写入cookies
            WebCookieHelper.SetSysUserCookie(result.ID, result.Name, result.LoginName, result.Tel, 15);
            GlobalMethod.log.Info(string.Format("{1}:{0}登录系统", result.Name, DateTime.Now.ToString()));
            return(Json(new
            {
                status = "1",
                message = "登录成功!"
            }));
        }