public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { bool result; IConfigurationRoot configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build(); bool.TryParse(configuration.GetValue <string>("AppSettings:Settings:useADlogin"), out bool useADlogin); if (useADlogin && !string.IsNullOrEmpty(Input.Tenant)) // if tenant is null, then assume that it is system level login. Go to the ValidateLogin which is used for regular login process first { result = await _signInManager.ADSigninAsync(Input.Tenant, Input.Password, Input.RememberMe); } else { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true result = await _signInManager.PasswordSignInAsync(Input.Tenant, Input.Email, Input.Password, Input.RememberMe); } if (result) { _logger.LogInformation("User logged in."); return(LocalRedirect(returnUrl)); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(Page()); } } // If we got this far, something failed, redisplay form return(Page()); }