public ActionResult Login(BuyerInfoViewModel buyer, string returnUrl) { ViewBag.ReturnUrl = returnUrl; IAuthProvider authProvider = new FormsAuthProvider(); if (ModelState.IsValid) { string msg; var user = BuyerInfoBll.GetModelByLoginName(buyer.LoginName, out msg); if (user != null) { if (user.Password.Equals(buyer.Password)) { Session["User"] = user; Session["IsGuest"] = false; authProvider.AuthSuccess(); var sellerList = BuyerInfoBll.GetSellerList(user.BuyerId, out msg); if (sellerList.Count > 1) { return(RedirectToAction("ListView", "Seller")); } else if (sellerList.Count == 1) { Session["SellerId"] = sellerList[0].SellerId; return(RedirectToAction("List", "Goods", new { sellerId = sellerList[0].SellerId })); } return(RedirectToAction("NoSeller", "Seller")); } else { ModelState.AddModelError("", "密码不正确请重新输入"); } } else { ModelState.AddModelError("", "登录失败:用户不存在" + msg); } } else { ModelState.AddModelError("", "输入信息有误,请重新输入"); } authProvider.AuthFailed(); return(View()); }
public ActionResult LoginAsGuest() { JsonResponseData response = new JsonResponseData() { IsSuccess = true, Msg = "登录成功" }; IAuthProvider authProvider = new FormsAuthProvider(); authProvider.AuthSuccess(); string msg; var guest = BuyerInfoBll.GetModel(1000031, out msg); if (guest == null) { response.IsSuccess = false; response.Msg = "游客身份获取失败"; return(Json(response)); } Session["User"] = guest; Session["IsGuest"] = true; var sellerList = BuyerInfoBll.GetSellerList(guest.BuyerId, out msg); if (sellerList.Count >= 1) { Session["SellerId"] = sellerList[0].SellerId; } else { Session["SellerId"] = 0; response.IsSuccess = false; response.Msg = "没有为体验用户指定卖家~"; return(Json(response)); } return(Json(response)); }
public ActionResult Login(bool isAutoLogin = true) { ViewBag.AppName = "趣订货电子商务有限公司"; if (isAutoLogin && Request.Cookies["name"] != null && Request.Cookies["pwd"] != null) { string msg; string name = Request.Cookies["name"].Value; string pwd = Request.Cookies["pwd"].Value; var user = BuyerInfoBll.GetModelByLoginName(name, out msg); if (user != null) { if (user.Password.Equals(pwd)) { Session["User"] = user; Session["IsGuest"] = false; IAuthProvider authProvider = new FormsAuthProvider(); authProvider.AuthSuccess(); var sellerList = BuyerInfoBll.GetSellerList(user.BuyerId, out msg); if (sellerList.Count > 1) { return(RedirectToAction("ListView", "Seller")); } else if (sellerList.Count == 1) { Session["SellerId"] = sellerList[0].SellerId; return(RedirectToAction("List", "Goods", new { sellerId = sellerList[0].SellerId })); } return(RedirectToAction("NoSeller", "Seller")); } } } return(View()); }
public ActionResult Login(BuyerInfoViewModel buyer, string returnUrl) { ViewBag.ReturnUrl = returnUrl; IAuthProvider authProvider = new FormsAuthProvider(); if (ModelState.IsValid) { string msg; var user = BuyerInfoBll.GetModelByLoginName(buyer.LoginName, out msg); if (user != null) { if (user.Password.Equals(buyer.Password)) { Session["User"] = user; authProvider.AuthSuccess(); return(Redirect(returnUrl ?? Url.Action("MainView", "Product", new { area = "Product" }))); } else { ModelState.AddModelError("", "密码不正确请重新输入"); } } else { ModelState.AddModelError("", "登录失败:" + msg); } } else { ModelState.AddModelError("", "输入信息有误,请重新输入"); } authProvider.AuthFailed(); return(View()); }