Example #1
0
        public void InsertTest()
        {
            AccountInfo entity = new AccountInfo()
            {
                Account  = "test",
                Password = EncryptHelper.EncryptMD5("123456" + "everglow"),
                Email    = "*****@*****.**",
                NickName = "测试账号",
                Status   = 1
            };
            var result = new AccountInfoBll().Insert(entity);

            Assert.AreEqual(1, 1);
        }
Example #2
0
 public ActionResult ForgetPwd(string Account)
 {
     if (!string.IsNullOrEmpty(Account.Trim()))
     {
         var account = new AccountInfoBll().QueryByAccountOrEmail(Account);
         if (account == null)
         {
             return(View());
         }
         EmailInfo mail = new EmailInfo();
         mail.Title         = "MBlog-重置密码";
         mail.Content       = "<a href=\"http://localhost:14561/Home/ChangePwd" + CacheHelper.Get <string>(account.Email + "_ActiveCode") + "\">如果不是本人操作,请忽略此邮件</a>";
         mail.RecipientMail = account.Email;
         EmailHelper.SendSysMail(mail);
     }
     return(View());
 }
Example #3
0
        public ActionResult Login(Login model, string returnUrl)
        {
            //if (file != null)
            //{
            //    var fileName = Path.Combine(Request.MapPath("~/Upload"), Path.GetFileName(file.FileName));
            //    FileInfo fileInfo = new FileInfo(fileName);
            //    if (!fileInfo.Directory.Exists)
            //        fileInfo.Directory.Create();
            //    file.SaveAs(fileName);
            //}
            if (!ModelState.IsValid)
            {
                return(View());
            }
            AccountInfo user = new AccountInfo();

            user.Password = EncryptHelper.EncryptMD5(model.Password + "everglow");
            user.Account  = model.Account;
            var account = new AccountInfoBll().Query(user);

            if (account == null)
            {
                return(new ContentResult()
                {
                    Content = "账号或密码错误!"
                });
            }
            else
            {
                Session["Account"] = account;
                if (string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect("Index"));
                }
                return(Redirect(returnUrl));
            }
        }
Example #4
0
        public ActionResult Register(Register model)
        {
            if (ModelState.IsValid)
            {
                model.NickName = "";

                model.Password = EncryptHelper.EncryptMD5(model.Password + "everglow");
                CacheHelper.Add <string>(model.Email + "_ActiveCode", Guid.NewGuid().ToString());
                var result = new AccountInfoBll().Insert(model) > 0;
                if (result)
                {
                    EmailInfo mail = new EmailInfo();
                    mail.Title         = "MBlog-注册激活邮件";
                    mail.Content       = "<a href=\"http://127.0.0.1/active/" + CacheHelper.Get <string>(model.Email + "_ActiveCode") + "\">去网站激活</a>";
                    mail.RecipientMail = model.Email;
                    EmailHelper.SendSysMail(mail);
                }
                return(new ContentResult()
                {
                    Content = result ? "成功" : "失败"
                });
            }
            return(View());
        }