 
       # Don't allow users to modify the user docs
       Meteor.users.deny({update: () -> true })
+
+      # Only allow job owners to manage or rerun jobs
+      myJobs.allow
+         manager: (userId, method, params) ->
+            ids = params[0]
+            unless typeof ids is 'object' and ids instanceof Array
+               ids = [ ids ]
+            numIds = ids.length
+            numMatches = myJobs.find({ _id: { $in: ids }, 'data.owner': userId }).count()
+            return numMatches is numIds
+
+         jobRerun: (userId, method, params) ->
+            id = params[0]
+            numMatches = myJobs.find({ _id: id, 'data.owner': userId }).count()
+            return numMatches is 1
 
       # Allow rules for security. Without these, no writes would be allowed by default
       myData.allow

               contentType: 'image/png'
               metadata: file.metadata
            job = myJobs.createJob('makeThumb',
               inputFileURL: Meteor.absoluteUrl("#{myData.baseURL[1..]}/#{file._id}")
               outputFileURL: Meteor.absoluteUrl("#{myData.baseURL[1..]}/put/#{outputFileId}")
               inputFileId: file._id

if Meteor.isServer

   myJobs.setLogStream process.stdout

   Meteor.startup () ->

      myJobs.startJobs()

      Meteor.publish 'allJobs', (clientUserId) ->
         # This prevents a race condition on the client between Meteor.userId() and subscriptions to this publish
         # See: https://stackoverflow.com/questions/24445404/how-to-prevent-a-client-reactive-race-between-meteor-userid-and-a-subscription/24460877#24460877
         if this.userId is clientUserId
            return myJobs.find({ 'data.owner': this.userId })
         else
            return []

      # Only publish files owned by this userId, and ignore temp file chunks used by resumable
      Meteor.publish 'allData', (clientUserId) ->
         # This prevents a race condition on the client between Meteor.userId() and subscriptions to this publish
         # See: https://stackoverflow.com/questions/24445404/how-to-prevent-a-client-reactive-race-between-meteor-userid-and-a-subscription/24460877#24460877
         if this.userId is clientUserId
