public ActionResult Logout() { string url = ""; this.Session.Clear(); var cookie = Response.Cookies["rememberMeLogin"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-100); } var acookie = Response.Cookies["rememberMeName"]; if (cookie != null) { acookie.Expires = DateTime.Now.AddDays(-100); } if (UserContext.Current.Groupid == (int)Common.CommonEnum.GroupOfCustomer.OpenShop) { url = "/Merchant/Company_Login"; } else { url = "/Login"; } YG.SC.OpenShop.Authentication.FormAuthenticationService fom = new FormAuthenticationService(); fom.SignOut(); return(Redirect(url)); }
public ActionResult Login(string LoginName, string Password, string rememberMe = "checked", string returnUrl = "") { this.Session.Clear(); var cookie = Response.Cookies["rememberMeLogin"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-100); } var acookie = Response.Cookies["rememberMeName"]; if (cookie != null) { acookie.Expires = DateTime.Now.AddDays(-100); } YG.SC.OpenShop.Authentication.FormAuthenticationService fom = new FormAuthenticationService(); fom.SignOut(); //获取账户 string message = "IsSuccss"; var entity = this._iCustomerService.GetEntityByNameAndPassword(LoginName, Password); if (entity == null || !entity.GroupId.HasValue || (CommonEnum.GroupOfCustomer)entity.GroupId != CommonEnum.GroupOfCustomer.Member && (CommonEnum.GroupOfCustomer)entity.GroupId != CommonEnum.GroupOfCustomer.OpenShop ) //前台只有会员和商家可以登录。 { entity = null; } if (entity == null) { message = "用户名或密码错误"; ViewBag.msg = message; return(View("index")); // if (!entity.Password.Equals(Password)) return "密码错误"; //if (entity.UserCd != UserCdSenior) return Json(new ResultModel(false, "权限错误")); } if (entity.GroupId == (int)YG.SC.Common.CommonEnum.GroupOfCustomer.Member) { WriteUserSession(entity, rememberMe); if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(HttpUtility.UrlDecode(returnUrl))); } return(Redirect("~/Customer/Memberindex/" + entity.Companyid)); } else { message = "用户名或密码错误"; ViewBag.msg = message; return(View()); } }
public ContentResult LoginAjax(string LoginName, string Password, string rememberMe = "checked", string returnUrl = "") { this.Session.Clear(); var cookie = Response.Cookies["rememberMeLogin"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-100); } var acookie = Response.Cookies["rememberMeName"]; if (cookie != null) { acookie.Expires = DateTime.Now.AddDays(-100); } YG.SC.OpenShop.Authentication.FormAuthenticationService fom = new FormAuthenticationService(); fom.SignOut(); //获取账户 string message = "IsSuccss"; var entity = this._iCustomerService.GetEntityByNameAndPassword(LoginName, Password); if (entity == null || !entity.GroupId.HasValue || (CommonEnum.GroupOfCustomer)entity.GroupId != CommonEnum.GroupOfCustomer.Member ) //只有会员可以登录。 { entity = null; } if (entity == null) { message = "用户名或密码错误"; ViewBag.msg = message; return(Content("0")); //登录失败。 } WriteUserSession(entity, rememberMe); return(Content("1")); //登录成功。 }