danirus / django-comments-xtd

A pluggable Django comments application with thread support, follow-up notifications, mail confirmation, like/dislike flags, moderation, a ReactJS plugin and Bootstrap 5.3.
https://django-comments-xtd.readthedocs.io
BSD 2-Clause "Simplified" License
594 stars 158 forks source link

Getting 403 Forbidden when trying to post a comment using the javascript plugin only when logged in #258

Open beasyx0 opened 3 years ago

beasyx0 commented 3 years ago

Hey there, so I followed the tutorial to a T and everything worked flawlessly until I got to the end and enabled the javascript plugin. Now whenever I'm logged in it says 'Sorry, your comment has been rejected' with a log message in my console 'WARNING 2021-01-21 16:18:04,155 log 807 139885087475456 Forbidden: /comments/api/comment/'. When I log out everything works fine. Can you try to guide me in the right direction to figure this out? I have no idea what this could be. Thanks.

Edit: Looks like im getting a 403 'rejected' from the WriteCommentSerializer from the comment_will_be_posted signal but that's as far as I've gotten so far. Sorry if this is the wrong place for this. I don't know if this is a 'bug' but thought I'd post anyways.

danirus commented 3 years ago

Hi @beasyx0, it seems to be the same issue as #256. It will be fixed in the next release, v2.8.2. Thanks for reporting it.

danirus commented 3 years ago

Duplicate of #256

danirus commented 3 years ago

Resolved with ebd355dab8f0ba6d59c9b9c7a1eecbc4d735d897.

beasyx0 commented 3 years ago

I know this was closed but it's still not working with the new release. Could be due to something else. I dunno. Thank you though.

danirus commented 3 years ago

Hi @beasyx0, I need more information. I thought it was the same issue as #256, but if not we need to get to know all the detauls. One thing you could do is to set up the comp demo site and check whether it works for you? There are instructions on how to do it here in the docs.

beasyx0 commented 3 years ago

Alright, I will be able to do that a little later today. Thank you for responding. I have quite the setup for my blog so I thought it may be something on my end and didn't want to make a big deal about it so that is a good way to tell if it's my setup or the app itself. I will report back in a bit. Thank you!

beasyx0 commented 3 years ago

HI danirus, Yes the demo project works as expected. Both the articles app and the quotes app. I'm guessing something within my blog is interfering with the comments app. This may not be a bug with your package. I don't even know where to start to troubleshoot this and I don't expect you to help me if the issue is on my end. Considering there doesn't seem to be anyone else having my issue you can go ahead and close this issue if you would like. Thank you for taking time to respond, the app is great and I hope I can figure it out. Thanks!

Edit: For reference I am using Cookiecutter Django which has a custom user model that subclasses 'AbstractUser'. Also using django version 3.

danirus commented 3 years ago

Tell me where I can get your code to take a look at it. If you prefer to keep it private, then create the minimum code to reproduce the issue. I don't mind to look into it. Maybe there is something about that AbstractUser that stays in the way of this application. It would be good to catch the issue.

beasyx0 commented 3 years ago

Sure. I just made my repo public. I don't know why I have it private to begin with. Have a look if you want just don't make fun of my code I've only been doing this under a year :) . Here's how to run it:

docker-compose -f local.yml build
docker-compose -f local.yml up -d
docker-compose -f local.yml run --rm django python manage.py shell
#inside shell
from djangoimposter.blog.builder import make_all_data
make_all_data(20)
# end shell
abiatarfestus commented 3 years ago

I'm also experiencing this issue in production when logged in. Has the cause been found? In development it works fine, but on production it displays "Sorry, your comment was rejected" and logs: Forbidden: /comments/api/comment/. In the console it points to a the following portion of jquery-3.3.1.min.js:2:

`try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w(" Githubissues.

  • Githubissues is a development platform for aggregating issues.