public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { TARSUser newuser = new TARSUser(); newuser.userName = model.UserName; newuser.permission = 1; TARSUserDBContext user = new TARSUserDBContext(); user.TARSUserList.Add(newuser); user.SaveChanges(); FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { LDAPConnection check = new LDAPConnection(); if (ModelState.IsValid) { // if (check.requestUser(model.UserName, model.Password)) // { model.UserName = "******"; model.Password = "******"; model.RememberMe = false; TARSUserDBContext TARSUserDB = new TARSUserDBContext(); // TARSUserDB.TARSUserList.Find(model.UserName); //check for and save any updates to the user's info in active directory CheckForActiveDirectoryChanges(model); FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } // } /* else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } */ } // If we got this far, something failed, redisplay form return View(model); }