public async Task SetPassword()

in app/Controllers/AccountController.cs [114:141]


        public async Task<IActionResult> SetPassword(SetPassword setPassword)
        {
            if (!ModelState.IsValid)
                return View(setPassword);

            var user = await _userManager.GetUserAsync(HttpContext.User);
            if (user == null)
                return NotFound();

            var changePassResult = await _userManager.ChangePasswordAsync(user, DbHelper.DefaultPassword, setPassword.NewPassword);

            if (!changePassResult.Succeeded)
            {
                foreach (var error in changePassResult.Errors)
                    ModelState.AddModelError(error.Code, error.Description);
                return View(setPassword);
            }

            if(user.EnforceChangePassword)
            {
                user.EnforceChangePassword = false;
                await _userManager.UpdateAsync(user);
            }

            _logger.LogInformation($"User {user.UserName} password changed.");

            return RedirectToAction("ChangePasswordConfirmation");
        }