@page "/account/register" @using Microsoft.AspNetCore.Identity @using Hcs.WebApp.Data @using Hcs.WebApp.Identity @inject IUserStore UserStore @inject UserManager UserManager @inject NotificationService NotificationService @inject SignInManager SignInManager @inject IdentityRedirectManager RedirectManager Регистрация аккаунта Регистрация @code { sealed class InputModel { public string UserName { get; set; } = ""; public string Password { get; set; } = ""; public string ConfirmPassword { get; set; } = ""; } [SupplyParameterFromForm] InputModel Input { get; set; } = new(); [SupplyParameterFromQuery] string? ReturnUrl { get; set; } async Task OnSubmit(InputModel mode) { var user = Activator.CreateInstance(); await UserStore.SetUserNameAsync(user, Input.UserName, CancellationToken.None); var result = await UserManager.CreateAsync(user, Input.Password); if (!result.Succeeded) { NotificationService.Notify(new NotificationMessage() { Severity = NotificationSeverity.Error, Summary = "Ошибка", Detail = string.Join(", ", result.Errors.Select(error => error.Description)) }); return; } await SignInManager.SignInAsync(user, isPersistent: false); RedirectManager.RedirectTo(ReturnUrl); } }