Skip to content

Commit 649345c

Browse files
author
Richard Jones
committed
if you're going to enforce class-level permissions...
...then enforce them at the class level
1 parent 012750d commit 649345c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

roundup/cgi/templating.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def is_view_ok(self):
874874
''' Is the user allowed to View the current class?
875875
Also check whether this is the current user's info.
876876
'''
877-
return self._db.security.hasPermission('Edit', self._client.userid,
877+
return self._db.security.hasPermission('View', self._client.userid,
878878
self._classname) or (self._nodeid == self._client.userid and
879879
self._db.user.get(self._client.userid, 'username') != 'anonymous')
880880

@@ -915,6 +915,26 @@ def __cmp__(self, other):
915915
return cmp(self._value, other._value)
916916
return cmp(self._value, other)
917917

918+
def is_edit_ok(self):
919+
''' Is the user allowed to Edit the current class?
920+
'''
921+
thing = HTMLDatabase(self._client)[self._classname]
922+
if self._nodeid:
923+
# this is a special-case for the User class where permission's
924+
# on a per-item basis :(
925+
thing = thing.getItem(self._nodeid)
926+
return thing.is_edit_ok()
927+
928+
def is_view_ok(self):
929+
''' Is the user allowed to View the current class?
930+
'''
931+
thing = HTMLDatabase(self._client)[self._classname]
932+
if self._nodeid:
933+
# this is a special-case for the User class where permission's
934+
# on a per-item basis :(
935+
thing = thing.getItem(self._nodeid)
936+
return thing.is_view_ok()
937+
918938
class StringHTMLProperty(HTMLProperty):
919939
hyper_re = re.compile(r'((?P<url>\w{3,6}://\S+)|'
920940
r'(?P<email>[-+=%/\w\.]+@[\w\.\-]+)|'

0 commit comments

Comments
 (0)