예제 #1
0
 public ActionResult Login(Account account)
 {
     //if (Session["ValidateCode"].ToString() != account.VerifyCode)
     //{
     //    ModelState.AddModelError("VerifyCode", "validate code is error");
     //    return View();
     //}
     if (!ModelState.IsValid)
     {
         return(View());
     }
     if (string.IsNullOrWhiteSpace(account.Name))
     {
         ModelState.AddModelError("Name", "消息:用户名不能为空!");
         return(View());
     }
     if (string.IsNullOrWhiteSpace(account.Password))
     {
         ModelState.AddModelError("Name", "消息:密码不能为空!");
         return(View());
     }
     MemoryCacheHelper.RemoveCacheAll();
     if (!LCLPrincipal.Login(account.Name, account.Password))
     {
         ModelState.AddModelError("Name", "消息:用户或密码错误,请重新输入!");
         return(View());
     }
     else
     {
         return(RedirectIndex());
     }
 }
예제 #2
0
        public JsonResult AjaxLogin(string name, string password)
        {
            var result = new Result(false);

            if (string.IsNullOrWhiteSpace(name))
            {
                result.Message = "消息:用户名不能为空!";
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                result.Message = "消息:密码不能为空!";
            }
            MemoryCacheHelper.RemoveCacheAll();
            if (!LCLPrincipal.Login(name, password))
            {
                result.Message = "消息:用户或密码错误,请重新输入!!";
            }
            else
            {
                result = new Result(true);
                var identity = LCL.LEnvironment.Principal.Identity as LCLIdentity;
                if (identity != null)
                {
                    if (identity.DepUserType == 2)
                    {
                        result.Message = "../../" + LCL.MvcExtensions.PageFlowService.PageNodes.FindPageNode("LayoutHome1").Value;
                    }
                    else
                    {
                        result.Message = "../../" + LCL.MvcExtensions.PageFlowService.PageNodes.FindPageNode("LayoutHome").Value;
                    }
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
 public ActionResult LogOut()
 {
     try
     {
         Request.Cookies.Clear();
         LCLPrincipal.Logout();
     }
     catch (Exception ex)
     {
         Logger.LogError("退出系统", ex);
     }
     FormsAuthentication.SignOut();
     return(Redirect(FormsAuthentication.LoginUrl));
 }