public async Task <IHttpActionResult> PostPasswordByNameAsync(string name, PasswordChangeDto passwords) { if (!Request.CheckAccess( GunchoResources.UserActions.Edit, GunchoResources.User, name, GunchoResources.Field, GunchoResources.UserFields.Password)) { return(Forbidden()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = userManager.FindByName(name); var result = await userManager.ChangePasswordAsync(user.Id, passwords.OldPassword, passwords.NewPassword); var errorResult = GetErrorResult(result); if (errorResult != null) { return(errorResult); } return(NoContent()); }
public Task <IHttpActionResult> PostMyPasswordAsync(PasswordChangeDto passwords) { return(PostPasswordByNameAsync(User.Identity.Name, passwords)); }