public async Task OnPostAsync()

in Application/UI/mvc-frontend/ImageRecognition/Areas/Identity/Pages/Account/ChangePassword.cshtml.cs [35:55]


        public async Task<IActionResult> OnPostAsync(string returnUrl = null)
        {
            if (!ModelState.IsValid) return Page();

            returnUrl = returnUrl ?? Url.Content("~/");

            var user = await _userManager.FindByEmailAsync(Input.Email);
            if (user == null) throw new InvalidOperationException("Unable to retrieve user.");

            var result = await _userManager.ChangePasswordAsync(user, Input.CurrentPassword, Input.NewPassword);

            if (result.Succeeded)
            {
                _logger.LogInformation("Changed password for user with ID '{UserId}'.", user.UserID);
                return LocalRedirect(returnUrl);
            }

            _logger.LogInformation("Unable to change password for user with ID '{UserId}'.", user.UserID);
            foreach (var item in result.Errors) ModelState.AddModelError(item.Code, item.Description);
            return Page();
        }