Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When adding comment, respond 403 if user is not authed
Since 2e6326e, which removed the code allowing anonymous comments with a captcha, we have effectively been assuming the session is properly authenticated when adding a comment - we look at `request.user` and `request.user.name` for the 'author' and don't do any checks, we just assume they were set. But if we have a cached session that has expired, or something like that, they will *not* be set. Without an explicit check, the error the client ultimately gets when trying to add the comment fails is not one which the client code recognizes as meaning 'reauthentication needed', so the client just sort of bails out. This was breaking apps like fedora-easy-karma which just retrieves a bunch of update info then tries to leave comments, once the cached session for the client expired. To fix this, we'll restore the check (removed in 2e6326e) that `author` actually gets set, and tweak it a bit to return 403 not 400 if it wasn't set. The client code *does* recognize a 403 response as meaning 'reauth needed', so this fixes the problem, and it's a more correct response than 400 anyway. Resolves: #3298 Signed-off-by: Adam Williamson <awilliam@redhat.com>
- Loading branch information