public async Task <IActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await userManager.FindByEmailAsync(model.Email); if (user != null && !user.EmailConfirmed && await userManager.CheckPasswordAsync(user, model.Password)) { ModelState.AddModelError(string.Empty, "Your Email has not yet been confirmed"); return(View(model)); } var result = await signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { var userInfo = await userManager.FindByEmailAsync(model.Email); //Save ID & Congregation ID var passedData = new LoginPassedDataViewModel() { Id = userInfo.Id, CongregationId = userInfo.FKPublisherCongregation, }; //Pass information on to Congregation Portal HttpContext.Session.SetObjectAsJson("userCredentials", passedData); var inspect = HttpContext.Session.GetObjectFromJson <LoginPassedDataViewModel>("userCredentials"); return(RedirectToAction(actionName: "Index", "CongregationPortal")); } } ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); } return(View(model)); }