public async Task <ActionResult> UpdateUserEasyPassword( [FromRoute, Required] Guid userId, [FromBody, Required] UpdateUserEasyPassword request) { if (!await RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true).ConfigureAwait(false)) { return(StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the easy password.")); } var user = _userManager.GetUserById(userId); if (user == null) { return(NotFound("User not found")); } if (request.ResetPassword) { await _userManager.ResetEasyPassword(user).ConfigureAwait(false); } else { await _userManager.ChangeEasyPassword(user, request.NewPw, request.NewPassword).ConfigureAwait(false); } return(NoContent()); }
public ActionResult UpdateUserEasyPassword( [FromRoute, Required] Guid userId, [FromBody] UpdateUserEasyPassword request) { if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true)) { return(Forbid("User is not allowed to update the easy password.")); } var user = _userManager.GetUserById(userId); if (user == null) { return(NotFound("User not found")); } if (request.ResetPassword) { _userManager.ResetEasyPassword(user); } else { _userManager.ChangeEasyPassword(user, request.NewPw, request.NewPassword); } return(NoContent()); }