async public Task <IActionResult> OnPostAsync()
        {
            string userId = String.Empty;

            return(await SecureHandlerAsync(async() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new StatusMessageException($"Type a valid username.");
                }

                var user = new ApplicationUser()
                {
                    Id = Guid.NewGuid().ToString(),
                    UserName = CreateInput.Username
                };

                if ((await _userDb.FindByNameAsync(user.UserName, CancellationToken.None)) != null)
                {
                    throw new StatusMessageException("User already exisits");
                }

                if (Regex.Match(user.UserName, ValidationExtensions.EmailAddressRegex).Success == true)
                {
                    user.Email = user.UserName;
                    user.EmailConfirmed = true;
                }

                user.PasswordHash = _passwordHasher.HashPassword(user, CreateInput.Password);

                var result = await _userDb.CreateAsync(user, CancellationToken.None);
                if (result.Succeeded == false)
                {
                    throw new StatusMessageException("Unkonwn error. Can't create user");
                }

                user = await _userDb.FindByNameAsync(user.UserName, CancellationToken.None);
                userId = user.Id;
            },
                                            onFinally : () => RedirectToPage("EditUser/Index", new { id = userId }),
                                            successMessage : "",
                                            onException : (ex) => RedirectToPage()));
        }
 async protected Task LoadUserAsync()
 {
     this.ApplicationUser = await _userDbContext.FindByNameAsync(User.Identity?.Name, new System.Threading.CancellationToken());
 }
 async public Task <ApplicationUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
 {
     return(await _dbContext.FindByNameAsync(normalizedUserName, cancellationToken));
 }