public ActionResult CompleteLogin(User user) { if (user.Email == null || user.Password == null) { ModelState.AddModelError("invalid-credentials", "Please enter an email and password."); return(View("Login", user)); } user.Email = user.Email.ToLower(); User currentUser = userSql.GetUserByEmail(user.Email); if (currentUser.Email == null) { ModelState.AddModelError("invalid-credentials", "That email isn't currently registered. "); ViewBag.RegisterInstead = true; return(View("Login", user)); } else if (currentUser.Password != user.Password) { ModelState.AddModelError("invalid-credentials", "Incorrect password"); return(View("Login", user)); } Session["background"] = GetBackground(); Session["userid"] = currentUser.UserID; Session["username"] = currentUser.DisplayName; TempData["existing-user"] = currentUser; switch (Session["anon"].ToString()) { case "Search": return(RedirectToAction("SearchText", "Home")); case "Deck": return(RedirectToAction("Index", "Deck")); default: return(RedirectToAction("UserHome")); } }