public ActionResult CompleteRegister(User newUser) { if (newUser.DisplayName == null || newUser.Email == null || newUser.Password == null || newUser.ConfirmPassword == null) { TempData["register-info-missing"] = true; return(RedirectToAction("Register")); } newUser.Email = newUser.Email.ToLower(); bool emailExists = userSql.CheckForEmail(newUser.Email); bool nameExists = userSql.CheckForName(newUser.DisplayName); if (emailExists) { ModelState.AddModelError("invalid-credentials", "That email has already been used to register on this site. "); ViewBag.LoginInstead = true; return(View("Register", newUser)); } else if (nameExists) { ModelState.AddModelError("invalid-credentials", "That name is already in use; please register with a different name."); ViewBag.LoginInstead = true; return(View("Register", newUser)); } if (!ModelState.IsValid) { return(View("Register", newUser)); } userSql.RegisterUser(newUser); User currentUser = userSql.GetUserByEmail(newUser.Email); Session["userid"] = currentUser.UserID; Session["username"] = currentUser.DisplayName; TempData["new-user"] = currentUser.DisplayName; switch (Session["anon"].ToString()) { case "Card": return(RedirectToAction("Index", "Card")); case "Deck": return(RedirectToAction("Index", "Deck")); default: return(RedirectToAction("UserHome")); } }