예제 #1
0
        public JsonResult UserLogin(string u_name, string u_pwd, string code)
        {
            object result = new { msg = "操作失败!", status = "0" };

            JMP.BLL.jmp_limit bll_limit = new JMP.BLL.jmp_limit();
            JMP.BLL.jmp_user  bll       = new JMP.BLL.jmp_user();
            JMP.MDL.jmp_user  model     = new JMP.MDL.jmp_user();

            var isDebug = ConfigurationManager.AppSettings["IsDebug"];

            if (!string.IsNullOrEmpty(isDebug) && isDebug == "true")
            {
                string yzcode = Session["ValidateCode"].ToString();
                if (yzcode != code)
                {
                    result = new { msg = "验证码错误!", success = "2" };
                    return(Json(result));
                }
            }

            model = bll.GetModel(u_name);

            //加密用户登录密码
            string jm_pwd = DESEncrypt.Encrypt(u_pwd);

            if (model != null && model.u_state == 1)
            {
                if ((model.u_email == u_name || model.u_phone == u_name) && model.u_password == jm_pwd)
                {
                    UserInfo.UserId     = model.u_id;
                    UserInfo.UserName   = model.u_realname;
                    UserInfo.UserNo     = model.u_email;
                    UserInfo.UserRoleId = model.u_role_id;
                    UserInfo.auditstate = model.u_auditstate.ToString();
                    DataTable dtLimit = bll_limit.GetAppUserLimitSession(model.u_id, model.u_role_id);
                    if (dtLimit.Rows.Count > 0)
                    {
                        Session["dtSession"] = dtLimit;
                        model.u_count       += 1;

                        string log = string.Format("开发者{0}于{1}登录聚米支付平台。", UserInfo.UserNo, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        AddLocLog.AddUserLog(UserInfo.UserId, 2, RequestHelper.GetClientIp(), "用户" + UserInfo.UserName + "登录。", log);
                        result = new { msg = "登录成功!", success = "1" };
                        return(Json(result));
                    }
                    else
                    {
                        result = new { msg = "权限不足!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            else
            {
                if (model == null)
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
                else if (model.u_state != 1)
                {
                    result = new { msg = "该账号已冻结!", success = "2" };
                }
            }
            return(Json(result));
        }
예제 #2
0
        public ActionResult UserLoginbygw(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
            {
                JMP.BLL.jmp_limit bll_limit = new JMP.BLL.jmp_limit();
                JMP.BLL.jmp_user  bll       = new JMP.BLL.jmp_user();
                JMP.MDL.jmp_user  model     = bll.GetModel(u_name);
                //加密用户登录密码
                string jm_pwd = u_pwd;
                if (model != null && model.u_state == 1)
                {
                    if ((model.u_email == u_name || model.u_phone == u_name) && model.u_password == jm_pwd)
                    {
                        UserInfo.UserId     = model.u_id;
                        UserInfo.UserName   = model.u_realname;
                        UserInfo.UserNo     = model.u_email;
                        UserInfo.UserRoleId = model.u_role_id;
                        DataTable dtLimit = bll_limit.GetAppUserLimitSession(model.u_id, model.u_role_id);
                        if (dtLimit.Rows.Count > 0)
                        {
                            Session["dtSession"] = dtLimit;
                            if (admname != "0")
                            {
                                string log = string.Format(admname + "从官网登录。", UserInfo.UserNo, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                AddLocLog.AddUserLog(UserInfo.UserId, 2, RequestHelper.GetClientIp(), admname + "从官网登录。", log);
                            }
                            result = new { msg = "登录成功!", success = "1" };
                        }
                        else
                        {
                            result = new { msg = "权限不足!", success = "2" };
                        }
                    }
                    else
                    {
                        result = new { msg = "用户名或密码错误!", success = "2" };
                    }
                }
                else
                {
                    if (model == null)
                    {
                        result = new { msg = "用户名或密码错误!", success = "2" };
                    }
                    else if (model.u_state != 1)
                    {
                        result = new { msg = "该账号已冻结!", success = "2" };
                    }
                }
            }
            ViewBag.message = result;
            return(View());
        }