Example #1
0
        public JsonResult Login(string loginName, string pwd)
        {
            MessageJSON message   = new MessageJSON();
            UsersInfo   usersinfo = usersbll.GetModelByName(loginName, Utility.DESEncrypt.GetMd5Str(pwd));

            if (usersinfo != null)
            {
                if (usersinfo.DeleteMark == 0)
                {
                    //清空验证码
                    Session["verifyCode"] = null;

                    //保存用户登录信息
                    SessionInfo.UserID    = usersinfo.UserID;
                    SessionInfo.UserName  = usersinfo.UserName;
                    SessionInfo.LoginName = usersinfo.LoginName;
                    SessionInfo.IsAdmin   = usersinfo.IsAdmin;

                    //添加登录日志
                    LoginLogInfo loginloginfo = new LoginLogInfo();
                    loginloginfo.UserID    = usersinfo.UserID;
                    loginloginfo.LoginName = usersinfo.LoginName;
                    loginloginfo.State     = 1;
                    loginloginfo.LoginIP   = Request.UserHostAddress;
                    loginloginfo.IPAddress = "";
                    loginlogbll.Add(null, loginloginfo);
                    message = new MessageJSON()
                    {
                        State = MessageState.success, Icon = MessageIcon.yes, Content = "登录成功"
                    };
                }
                else
                {
                    message = new MessageJSON()
                    {
                        State = MessageState.fail, Icon = MessageIcon.no, Content = "用户已被删除"
                    };
                }
            }
            else
            {
                message = new MessageJSON()
                {
                    State = MessageState.fail, Icon = MessageIcon.no, Content = "账户或密码有错误"
                };
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }