public ActionResult LogOnPost(YaleFigureSkatingClub.Entities.User user, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(user.Username, user.Password)) { log.InfoFormat ("User '{0}' logged in successfully.", user.Username); FormsAuthentication.SetAuthCookie(user.Username, false); if (String.IsNullOrEmpty(returnUrl)) { return RedirectToAction("Index", "Membership"); } else { return Redirect(returnUrl); } } else { log.InfoFormat ("User '{0}' unsuccessful login attempt.", user.Username); ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View("LogOn", user); }
public ActionResult CreateSubmit(YaleFigureSkatingClub.Entities.User user) { if (!ModelState.IsValid) { return View ("Create", user); } session.Save (user); FormsAuthentication.SetAuthCookie(user.Username, false); TempData["message"] = "Your account has been successfully created!"; return RedirectToAction("Index", "Membership"); }