public async Task <IActionResult> ConfirmEmailAddress(string token, string email)
        {
            var user = await _accountManager.GetUserByEmailAsync(email);

            if (user == null)
            {
                throw new ApiException(HttpStatusCode.NotFound, "Email is incorrect");
            }

            var reset = await _accountManager.ResetAccessFailedCountAsync(user);

            if (!reset.Succeeded)
            {
                throw new ApiException().ParseIdentityError(reset);
            }

            if (await _accountManager.IsEmailConfirmedAsync(user))
            {
                return(Redirect($"{Extensions.AdminUrl}/login"));
            }

            var result = await _accountManager.ConfirmEmailAsync(user, token);

            if (!result.Succeeded)
            {
                throw new ApiException().ParseIdentityError(result);
            }

            return(Redirect($"{Extensions.AdminUrl}/login?EmailConfirmed=true"));
        }
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                return(View(ModelErrorsResource.UserNotFound));
            }
            var result = await _accountManager.ConfirmEmailAsync(userId, code);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(ModelErrorsResource.EmailNotConfirmed));
            }
        }
        public async Task <IActionResult> ConfirmEmail(string userId, string code)
        {
            ApplicationUser appUser = await _accountManager.GetUserByIdAsync(userId);

            if (appUser == null)
            {
                return(NotFound(userId));
            }

            var result = await _accountManager.ConfirmEmailAsync(appUser, code);

            if (!result.Succeeded)
            {
                return(BadRequest($"Confirming email failed for user \"{appUser.UserName}\". Errors: {string.Join(", ", result.Errors)}"));
            }

            return(Accepted());
        }
 [HttpPost("confirmemail")] // POST: api/account/confirmemail
 public async Task <JToken> ConfirmEmailAsync(JToken emailAndCode) => (ModelState.IsValid ? await _accountManager.ConfirmEmailAsync(emailAndCode["email"].ToString(), emailAndCode["code"]?.ToString()) : _defaultInvalidResponse).ToJToken();