Ejemplo n.º 1
0
        public ActionResult Index(Users model)
        {
            string PrevTime =  Public.CommonHelper.GetCookie("MyReg", "Time");
            if (PrevTime != "")
            {
                TempData["Msg"] = "30���Ӻ����ٹ���ע��";
                return View();
            }

            model.UserName = GetNoSpaceStr(model.UserName);
            if (model.UserName.Length < 2)
            {
                TempData["Msg"] = "�û�������Ҫ�������ַ�";
                return View();
            }
            if (model.UserName.Length > 15)
            {
                TempData["Msg"] = "�û������ܳ���15���ַ�";
                return View();
            }
            if (MyText.CheckHaveSymbol(model.UserName))
            {
                TempData["Msg"] = "�û����в��ܺ��������ַ�";
                return View();
            }
            if (CommonCache.FilterTexthHave(model.UserName))
            {
                TempData["Msg"] = "�û����а�����дʣ�����ע��";
                return View();
            }
            bizUsers provider = new bizUsers();
            if (provider.CheckUserName(model.UserName) == true)
            {
                TempData["Msg"] = "���û����Ѿ���ע��";
                return View();
            }

            model.UserColor = model.Sex == 0 ? "red" : "blue";
            int userID = provider.Add(model);

            Public.CommonHelper.LoginDeal(HttpContext, model.UserName, MyText.GetEncrypt(model.Password));

            //����Cookie
            HttpCookie myc = new HttpCookie("MyReg");
            myc["Time"] = DateTime.Now.ToString();
            myc.Expires = DateTime.Now.AddMinutes(30);
            Response.AppendCookie(myc);

            return RedirectToAction("RegisterOK");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改新密码
        /// </summary>
        /// <param name="model"></param>
        /// <param name="newPwd"></param>
        public void ModPassword(Users model, string newPwd)
        {
            Users modelNew = model;
            modelNew.Attach();
            modelNew.Password = newPwd;
            modelNew.Detach();

            Update(modelNew);
        }