Skip to content

Commit

Permalink
Add support for anonymous users in get_roles. Refs #339
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroel committed Jan 4, 2017
1 parent 04010d4 commit cd4cea1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Support user.get_roles for anonymous users. Refs #339
[jaroel]


1.5.1 (2016-12-06)
Expand Down
6 changes: 5 additions & 1 deletion src/plone/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ def get_roles(username=None, user=None, obj=None, inherit=True):
else:
username = user.getId()

user = portal_membership.getMemberById(username)
if username is None and user is None:
user = portal_membership.getAuthenticatedMember()
else:
user = portal_membership.getMemberById(username)

if user is None:
raise UserNotFoundError

Expand Down

1 comment on commit cd4cea1

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaroel Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.api/20/violations

src/plone/api/content.py:269:1: C901 'delete' is too complex (15)
src/plone/api/content.py:361:1: C901 '_wf_transitions_for' is too complex (13)
src/plone/api/content.py:426:1: C901 'transition' is too complex (13)
src/plone/api/portal.py:284:13: Q000 Remove bad quotes.
src/plone/api/portal.py:285:13: Q000 Remove bad quotes.
src/plone/api/portal.py:326:13: Q000 Remove bad quotes.

Follow these instructions to reproduce it locally.

Please sign in to comment.