Hi,
I am trying to update comment from default service call. I am passing session in header of logged in user due to this drupal service will consider that user as logged in user and update comment by that user name.
Here is my code,
var obj = {
//"subject":"liJmJfpqMX",
"comment_body":{"und":[{"value":" updated ..this is comment is from rest service.."}]},
"cid":cid
};
$.ajax({
url: "MY_SITE_URL/my_services/comment/"+ 89+".json",
headers: {
"session": "SESS49960de5880e8c687434170f6476605b=m4Lw6KqhPCnnN7ni9IgGA4eaoyWeI7YwWOEbFPoPnpw",
"Cookie": "SESS49960de5880e8c687434170f6476605b=m4Lw6KqhPCnnN7ni9IgGA4eaoyWeI7YwWOEbFPoPnpw",
},
crossDomain: true,
type: 'PUT',
ContentType: "application/json",
"data" : obj,
dataType: 'json',
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('VIew Comment - failed to show'+ textStatus + errorThrown);
},
success: function (data) {
alert("Success :) ");
}
});
}
In above code I am passing session to one user(A) and given comment is of user is posted by another user(B), once i run this code comment is updated and author is set to user A.
But as per pemissions i set only author can update self comments.
Please suggest me solution!!!
Thanks in advance!!
Comments
Comment #1
kylebrowning commentedYou haven't passed the author of the comment, so its automatically updated to user A, because USER A is the one updating the comment.
Comment #2
marcingy commentedComment #3
marcingy commentedComment #4
Madhuri A commentedBut after running above code it should have to give error like 'Access denied.'
Can you please update the code to pass author?
Comment #5
Madhuri A commentedPassing author like,
var obj = {
"subject":"testing comment...",
"comment_body":{"und":[{"value":" Testing......."}]},
"cid":cid,
"uid":23060
};
but not useful.
Comment #6
kylebrowning commentedComment #7
Madhuri A commentedComment #8
marcingy commentedThere is no patch so this is simply active
Comment #9
kylebrowning commentedCleaning issue queue, if you want to work on this, re-open the ticket.