Пример #1
0
        private object DoLogin(string userName, string userPwd)
        {
            object result;
            var    bllLimit = new jmp_limit();
            var    bll      = new CoAgent();
            var    model    = bll.GetModel(userName);
            //加密用户登录密码
            var jmPwd = DESEncrypt.Encrypt(userPwd).ToLower();

            if (model != null)
            {
                if (model.AuditState != 1 && model.State != 0)
                {
                    result = new { msg = "您的账号未审核或者已冻结请联系运营人员!", success = "2" };
                    return(result);
                }
                if (model.LoginName == userName && model.Password.ToLower() == jmPwd)
                {
                    UserInfo.UserId     = model.Id;
                    UserInfo.UserName   = model.DisplayName;
                    UserInfo.UserNo     = model.LoginName;
                    UserInfo.UserRoleId = model.RoleId;
                    var dtLimit = bllLimit.GetAgentLimitSession(model.Id, model.RoleId);
                    if (dtLimit.Rows.Count > 0)
                    {
                        Session["dtSession"] = dtLimit;
                        model.LoginCount    += 1;
                        bll.Update(model);
                        Logger.OperateLog("登录代理商平台", "用户('" + UserInfo.UserName + "')于{'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'}登录代理商平台");
                        // var log = string.Format("用户({0})于{1}登录后台系统。", UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        // AddLocLog.AddLog(int.Parse(UserInfo.UserId), 2, RequestHelper.GetClientIp(), "用户" + UserInfo.UserName + "登录。", log);
                        result = new { msg = "登录成功!", success = "1" };
                    }
                    else
                    {
                        result = new { msg = "权限不足!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            else
            {
                result = new { msg = "用户名或密码错误!", success = "2" };
            }

            return(result);
        }
Пример #2
0
        public ActionResult UserLoginbyadm(string qs)
        {
            object result  = "";
            string ms      = JMP.TOOL.DESEncrypt.Decrypt(qs);
            string u_name  = ms.Split(';')[0].ToString();
            string u_pwd   = ms.Split(';')[1].ToString();
            string admname = ms.Split(';')[2].ToString();
            string admtime = ms.Split(';')[3].ToString();

            if (Convert.ToDateTime(admtime).AddMinutes(5) < System.DateTime.Now)
            {
                result = new { msg = "登录超时,后台密码失效,请从新刷新后台用户列表!", success = "2" };
            }
            else
            {
                var bllLimit = new jmp_limit();
                var bll      = new CoAgent();
                var model    = bll.GetModel(u_name);
                //加密用户登录密码

                if (model != null)
                {
                    if (model.AuditState != 1 || model.State != 0)
                    {
                        result = new { msg = "您的账号未审核或者已冻结请联系运营人员!", success = "2" };
                    }

                    else if (model.LoginName == u_name && model.Password.ToLower() == u_pwd.ToLower())
                    {
                        UserInfo.UserId     = model.Id;
                        UserInfo.UserName   = model.DisplayName;
                        UserInfo.UserNo     = model.LoginName;
                        UserInfo.UserRoleId = model.RoleId;
                        var dtLimit = bllLimit.GetAgentLimitSession(model.Id, model.RoleId);
                        if (dtLimit.Rows.Count > 0)
                        {
                            Session["dtSession"] = dtLimit;
                            model.LoginCount    += 1;
                            bll.Update(model);
                            var log = string.Format("管理员({0})用{1}在{2}登录系统。", admname, UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            Logger.OperateLog("登录日志", log);
                            result = new { msg = "登录成功!", success = "1" };
                        }
                        else
                        {
                            result = new { msg = "权限不足!", success = "2" };
                        }
                    }
                    else
                    {
                        result = new { msg = "用户名或密码错误!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            ViewBag.message = result;
            return(View());
        }