public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/account/login"); if (ModelState.IsValid) { var user = new FinancialChatUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public static async Task SeedAsync(UserManager <FinancialChatUser> userManager) { var defaultUser = new FinancialChatUser { UserName = "******", Email = "*****@*****.**" }; if (userManager.Users.All(u => u.Id != defaultUser.Id)) { await userManager.CreateAsync(defaultUser, "Chat123$"); } var anotherUser = new FinancialChatUser { UserName = "******", Email = "*****@*****.**" }; if (userManager.Users.All(u => u.Id != anotherUser.Id)) { await userManager.CreateAsync(anotherUser, "Chat123$"); } }