Exemplo n.º 1
0
        public JsonResult LoginService(LoginModel ModelInfo)
        {
            try
            {
                if (GlobalController.AuthenticateUser(ModelInfo.UserName, ModelInfo.Password, true))
                {
                    //FormsAuthentication.SetAuthCookie(ModelInfo.UserName, true);

                    return(Json(ReturnInfo.Success(string.Empty)));
                }
                else
                {
                    return(Json(ReturnInfo.Error("用户名或密码错误")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ReturnInfo.Error(ex.Message)));
            }
        }
Exemplo n.º 2
0
        public ActionResult Login(LoginModel ModelInfo, string ReturnUrl)
        {
            if (GlobalController.AuthenticateUser(ModelInfo.UserName, ModelInfo.Password, true))
            //if (ModelInfo.UserName == "Admin" && ModelInfo.Password == "Admin")
            {
                //FormsAuthentication.SetAuthCookie(ModelInfo.UserName, true);

                if (ReturnUrl.IsEmpty())
                {
                    return(RedirectToAction("Index", "Manage"));
                }
                else
                {
                    return(Redirect(ReturnUrl));
                }
            }
            else
            {
                ModelState.AddModelError("", "用户名或密码错误");
            }

            return(View());
        }