tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343396256


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -69,32 +69,34 @@ object ResourceAccess {
     ).flatMap(record => Option(record.value1()))
       .contains(uid)
 
+  /** The owner always has WRITE, whatever their own access row says. */
   def privilegeOf[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): PrivilegeEnum =
-    Option(
-      ctx
-        .select(resource.privilegeField)
-        .from(resource.accessTable)
-        .where(
-          resource.accessIdField
-            .eq(id)
-            .and(resource.accessUidField.eq(uid))
-        )
-        .fetchOneInto(classOf[PrivilegeEnum])
-    ).getOrElse(PrivilegeEnum.NONE)
+    if (userOwns(ctx, resource, id, uid)) PrivilegeEnum.WRITE
+    else
+      Option(
+        ctx
+          .select(resource.privilegeField)
+          .from(resource.accessTable)
+          .where(
+            resource.accessIdField
+              .eq(id)
+              .and(resource.accessUidField.eq(uid))
+          )
+          .fetchOneInto(classOf[PrivilegeEnum])
+      ).getOrElse(PrivilegeEnum.NONE)
 
   def userHasWriteAccess[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): Boolean =
-    userOwns(ctx, resource, id, uid) ||
-      privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
+    privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
 
   def userHasReadAccess[R <: Record, A <: Record](

Review Comment:
   Done: isPublic || privilegeOf != NONE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to