diff --git a/cioppino/twothumbs/browser/like.py b/cioppino/twothumbs/browser/like.py index cc14bf1..fc90acb 100644 --- a/cioppino/twothumbs/browser/like.py +++ b/cioppino/twothumbs/browser/like.py @@ -62,20 +62,21 @@ class LikeThisShizzleView(BrowserView): def __call__(self, REQUEST, RESPONSE): registry = getUtility(IRegistry) anonuid = None - if not registry.get('cioppino.twothumbs.anonymousvoting', False): - # First check if the user is allowed to rate - portal_state = getMultiAdapter((self.context, self.request), - name='plone_portal_state') - if portal_state.anonymous(): + anonymous_voting = registry.get('cioppino.twothumbs.anonymousvoting', False) + portal_state = getMultiAdapter((self.context, self.request), + name='plone_portal_state') + + if portal_state.anonymous(): + if not anonymous_voting: return RESPONSE.redirect('%s/login?came_from=%s' % (portal_state.portal_url(), REQUEST['HTTP_REFERER']) ) - else: - anonuid = self.request.cookies.get(COOKIENAME, None) - if anonuid is None: - anonuid = str(uuid4()) - RESPONSE.setCookie(COOKIENAME, anonuid) + else: + anonuid = self.request.cookies.get(COOKIENAME, None) + if anonuid is None: + anonuid = str(uuid4()) + RESPONSE.setCookie(COOKIENAME, anonuid) form = self.request.form action = None diff --git a/docs/HISTORY.rst b/docs/HISTORY.rst index fb18eb0..0fbd821 100644 --- a/docs/HISTORY.rst +++ b/docs/HISTORY.rst @@ -6,6 +6,8 @@ Changelog - HTML render fixes. [andreasma] +- Fix bug in like view that prevented authenticated user id from being used + in votes when anonymous voting was enabled [cguardia] 1.8 (2014-11-07)