public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            ReturnUrl = returnUrl;
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = Input.UserName, Email = Input.Email, PhoneNumber = Input.PhoneNumber
                };
                IEnumerable <Claim> claims = new List <Claim>
                {
                    new Claim(JwtClaimTypes.Name, Input.UserName),
                    new Claim(JwtClaimTypes.Email, Input.Email),
                    new Claim(JwtClaimTypes.PhoneNumber, Input.PhoneNumber),
                    new Claim(JwtClaimTypes.Role, AppRoleNames.ECommerce_End_User)
                };

                var result = await _userManager.CreateAsync(user, Input.Password);

                // Add User To Roles
                result = await _userManager.AddToRoleAsync(user, AppRoleNames.ECommerce_End_User);

                // Add Claim To User
                result = await _userManager.AddClaimsAsync(user, claims);

                if (result.Succeeded)
                {
                    logModel.LogMessage = "User created a new account with password.";

                    // Logging
                    await _loggingServices.LogAsync(logModel);

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id.ToString(), code, Request.Scheme);
                    await _emailSender.SendEmailConfirmationAsync(Input.Email, callbackUrl);

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(Url.GetLocalUrl(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 async Task <IActionResult> OnPostSendVerificationEmailAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var callbackUrl = Url.EmailConfirmationLink(user.Id.ToString(), code, Request.Scheme);
            await _emailSender.SendEmailConfirmationAsync(user.Email, callbackUrl);

            StatusMessage = "Verification email sent. Please check your email.";
            return(RedirectToPage());
        }