Skip to content

Commit

Permalink
Uses PloneManageUsers variable instead of the string
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl committed Nov 9, 2023
1 parent 08f8f87 commit e21ac6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/plone/restapi/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# permissions. Granted to Anonymous (i.e. everyone) by default via rolemap.xml

UseRESTAPI = "plone.restapi: Use REST API"

PloneManageUsers = "Plone Site Setup: Users and Groups"
3 changes: 2 additions & 1 deletion src/plone/restapi/services/users/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from plone.restapi.bbb import ISecuritySchema
from plone.restapi.deserializer import json_body
from plone.restapi.interfaces import ISerializeToJson
from plone.restapi.permissions import PloneManageUsers
from plone.restapi.services import Service
from Products.CMFCore.permissions import AddPortalMember
from Products.CMFCore.permissions import SetOwnPassword
Expand Down Expand Up @@ -244,7 +245,7 @@ def _error(self, status, _type, msgid):
@property
def can_manage_users(self):
sm = getSecurityManager()
return sm.checkPermission("Plone Site Setup: Users and Groups", self.context)
return sm.checkPermission(PloneManageUsers, self.context)

@property
def can_set_own_password(self):
Expand Down
5 changes: 3 additions & 2 deletions src/plone/restapi/services/users/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from plone.namedfile.browser import USE_DENYLIST
from plone.namedfile.utils import stream_data
from plone.restapi.interfaces import ISerializeToJson
from plone.restapi.permissions import PloneManageUsers
from plone.restapi.services import Service
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import normalizeString
Expand Down Expand Up @@ -177,11 +178,11 @@ def _get_filtered_users(self, query, groups_filter, search_term, limit):

def has_permission_to_query(self):
sm = getSecurityManager()
return sm.checkPermission("Plone Site Setup: Users and Groups", self.context)
return sm.checkPermission(PloneManageUsers, self.context)

def has_permission_to_enumerate(self):
sm = getSecurityManager()
return sm.checkPermission("Plone Site Setup: Users and Groups", self.context)
return sm.checkPermission(PloneManageUsers, self.context)

def has_permission_to_access_user_info(self):
sm = getSecurityManager()
Expand Down
3 changes: 2 additions & 1 deletion src/plone/restapi/services/users/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from OFS.Image import Image
from plone.restapi import _
from plone.restapi.bbb import ISecuritySchema
from plone.restapi.permissions import PloneManageUsers
from plone.restapi.services import Service
from Products.CMFCore.permissions import ManagePortal
from Products.CMFCore.permissions import SetOwnPassword
Expand Down Expand Up @@ -160,7 +161,7 @@ def reply(self):
@property
def can_manage_users(self):
sm = getSecurityManager()
return sm.checkPermission("Plone Site Setup: Users and Groups", self.context)
return sm.checkPermission(PloneManageUsers, self.context)

@property
def can_set_own_password(self):
Expand Down

0 comments on commit e21ac6d

Please sign in to comment.