public ActionResult LogOn(LogOnModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } mUser user = user_get.Login(model.UserName, model.Password); if (user == null) { ModelState.AddModelError("", "提供的用户名或密码不正确。"); return(View(model)); } var roles = user_get.RoleGetByuser(user.Id); var auths = user_get.AuthGetByuser(user.Id); authentication.SetAuthCookie(this.HttpContext, AuthenticationTicketBuilder.CreateTicket(user, roles, auths)); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Use", "Seat")); } }
public ActionResult Register(RegisterModel model) { if (!ModelState.IsValid) { return(View(model)); } if (user_get.UserCheckNameExist(model.UserName)) { ModelState.AddModelError("", "用户名已存在。"); return(View(model)); } mUser user = new mUser { Name = model.UserName, Password = model.Password }; user_sub.UserAdd(user); //user_sub.UserAddByrole(user, "Guest"); var roles = user_get.RoleGetByuser(user.Id); var auths = user_get.AuthGetByuser(user.Id); authentication.SetAuthCookie(this.HttpContext, AuthenticationTicketBuilder.CreateTicket(user, roles, auths)); return(RedirectToAction("Use", "Seat")); }