Esempio n. 1
0
        public async Task <ActionResult> Login(InputLogin model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //var result = loginOnManager.LoginOn(model);
            using (SubBugEntities db = new SubBugEntities())
            {
                var Pwd    = md5.MD5Encrypt(model.LoginPwd);
                var result = await db.TB_LoginOn.FirstOrDefaultAsync(l => l.LoginNo == model.LoginNo && l.LoginPwd == Pwd);

                if (result != null)
                {
                    Session["LoginName"] = result;
                    if (((TB_LoginOn)Session["LoginName"]).AId != 1)
                    {
                        return(RedirectToAction("Index", "Follow"));
                    }

                    return(RedirectToAction("List", "Home"));
                }

                ViewData["info"] = "失败!";
                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult SetPwd(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var lg = db.TB_LoginOn.FirstOrDefault(t => t.LId == id);

            lg.LoginPwd = md5.MD5Encrypt("123456");
            db.SaveChanges();
            return(Content("<script>alert('密码重置成功!');history.go(-1);</script>"));
        }
Esempio n. 3
0
        protected override void Seed(SubmitBug.DAL.SubBugEntities context)
        {
            if (context.TB_UserAccess.Any() && context.TB_LoginOn.Any())
            {
                return;
            }
            else
            {
                if (!context.TB_UserAccess.Any())
                {
                    List <TB_UserAccess> listUserAccess = new List <TB_UserAccess>()
                    {
                        new TB_UserAccess()
                        {
                            AccessName = "Users"
                        },
                        new TB_UserAccess()
                        {
                            AccessName = "PowerUsers"
                        },
                        new TB_UserAccess()
                        {
                            AccessName = "Follower"
                        }
                        ,
                        new TB_UserAccess()
                        {
                            AccessName = "Guest"
                        }
                    };
                    context.TB_UserAccess.AddRange(listUserAccess);
                    context.SaveChanges();
                }
                if (!context.TB_LoginOn.Any())
                {
                    MD5DataEncryption md5         = new MD5DataEncryption();
                    List <TB_LoginOn> listLoginOn = new List <TB_LoginOn>()
                    {
                        new TB_LoginOn()
                        {
                            LoginNo    = "Guest",
                            LoginName  = "Guest",
                            LoginPwd   = md5.MD5Encrypt("123456"),
                            LPhone     = "1234567890",
                            ComputerNo = "T",
                            AId        = 1
                        },
                        new TB_LoginOn()
                        {
                            LoginNo    = "Admin",
                            LoginName  = "Admin",
                            LoginPwd   = md5.MD5Encrypt("12345678"),
                            LPhone     = "1234567890",
                            ComputerNo = "T",
                            AId        = 2
                        }
                    };

                    context.TB_LoginOn.AddRange(listLoginOn);
                    context.SaveChanges();
                }
            }
        }