5416: Allow users with repo write permission to update modified_at.
[arvados.git] / services / api / app / models / repository.rb
index f159b48bdacd62ca841ade0f42a394163d5bd084..0189ee7236940934831713ff18b2b92ffb53bd87 100644 (file)
@@ -22,7 +22,15 @@ class Repository < ArvadosModel
   def permission_to_create
     current_user and current_user.is_admin
   end
+
   def permission_to_update
-    current_user and current_user.is_admin
+    return false if not current_user
+    return true if current_user.is_admin
+    # For normal objects, this is a way to check whether you have
+    # write permission. Repositories should be brought closer to the
+    # normal permission model during #4253. Meanwhile, we'll
+    # special-case this so arv-git-httpd can detect write permission:
+    return super if changed_attributes.keys - ['modified_at', 'updated_at'] == []
+    false
   end
 end