Exemplo n.º 1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                //return RedirectToLocal(returnUrl);
                if (db.BEmplyees.Where(m => m.NumberEmp == model.UserName && !(m.isDelete!=null&&m.isDelete == true)).Count() > 0)
                {
                    return RedirectToLocal("/");
                }else
                {
                    WebSecurity.Logout();
                    ModelState.AddModelError("", "该用户已被管理禁用.");
                    return View(model);
                }

            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "用户名或密码错误.");

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult LoginInner(LoginModel model)
        {
            ViewBag.isTong = false;
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                //return RedirectToLocal(returnUrl);
                if (db.BEmplyees.Where(m => m.NumberEmp == model.UserName && !(m.isDelete != null && m.isDelete == true)).Count() > 0)
                {
                    //return Content("登录成功!");
                    ViewBag.isTong = true;
                    ViewBag.uName = model.UserName;
                    return PartialView();

                }
                else
                {
                    WebSecurity.Logout();
                    //return Content("该用户已被管理禁用.");
                    ModelState.AddModelError("", "该用户已被管理禁用.");
                    return PartialView(model);
                }

            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "用户名或密码错误.");
            //return Content("用户名或密码错误.");
            return PartialView(model);
        }