Browse Source

fixes rights control on not_shared document

Damien Accorsi 10 years ago
parent
commit
24423406f3
1 changed files with 14 additions and 14 deletions
  1. 14 14
      pboard/pboard/lib/auth.py

+ 14 - 14
pboard/pboard/lib/auth.py View File

@@ -7,18 +7,19 @@ import logging as l
7 7
 
8 8
 DIRTY_canReadOrCanWriteSqlQuery = """
9 9
 SELECT
10
-    node_id
10
+    pgn.node_id
11 11
 FROM
12 12
     pod_group_node AS pgn
13
-    join pod_user_group AS pug on pug.group_id = pgn.group_id
14
-    join pod_user AS pu ON pug.user_id = pu.user_id
13
+    JOIN pod_nodes AS pn ON pn.node_id = pgn.node_id AND pn.is_shared = 't'
14
+    JOIN pod_user_group AS pug ON pug.group_id = pgn.group_id
15
+    JOIN pod_user AS pu ON pug.user_id = pu.user_id
15 16
 WHERE
16 17
     rights > :excluded_right_low_level
17 18
     AND email_address = :email
18
-    AND node_id = :node_id
19
+    AND pgn.node_id = :node_id
19 20
 UNION
20 21
     SELECT
21
-        node_id
22
+        pnn.node_id
22 23
     FROM
23 24
         pod_nodes AS pnn,
24 25
         pod_user AS puu
@@ -53,13 +54,12 @@ class can_write(Predicate):
53 54
         pass
54 55
 
55 56
     def evaluate(self, environ, credentials):
56
-        if 'node_id' in environ['webob.adhoc_attrs']['validation']['values']:
57
-            node_id = environ['webob.adhoc_attrs']['validation']['values']['node_id']
58
-            if node_id!=0:
59
-                has_right = session.execute(
60
-                    DIRTY_canReadOrCanWriteSqlQuery,
61
-                    {"email":credentials["repoze.who.userid"], "node_id":node_id, "excluded_right_low_level": 1}
62
-                )
63
-                if has_right.rowcount == 0 :
64
-                    self.unmet()
57
+        node_id = environ['webob.adhoc_attrs']['validation']['values']['node_id']
58
+        if node_id!=0:
59
+            has_right = session.execute(
60
+                DIRTY_canReadOrCanWriteSqlQuery,
61
+                {"email":credentials["repoze.who.userid"], "node_id":node_id, "excluded_right_low_level": 1}
62
+            )
63
+            if has_right.rowcount == 0 :
64
+                self.unmet()
65 65