   unflagIsLowQuality:(callback)->
     @_flagIsLowQuality no, 1, callback
 
-  modify: secure (client, body, callback) ->
-    {delegate} = client.connection
-    return callback new KodingError "Access Denied"  unless delegate.getId().equals @originId
-    body = body?.trim()
-    if not body? or body is ""
-      return callback new KodingError "Comment cannot be empty"
+  modify: permit
+    advanced: [
+        { permission: 'edit own comments', validateWith: Validators.own }
+        { permission: 'edit comments' }
+      ]
+    success: (client, body, callback) ->
+      {delegate} = client.connection
 
-    return @update $set: {body}, callback unless body is @body
+      body = body?.trim()
+      if not body? or body is ""
+        return callback new KodingError "Comment cannot be empty"
 
-    callback null
+      editedBy = ObjectRef(delegate)
+      return @update $set: {body, editedAt: new Date, editedBy}, callback unless body is @body
+
+      callback null

        { name: 'updateInstance' }
        { name: 'RemovedFromCollection' }
      ]
    schema         :
      isLowQuality : Boolean
      body         :


  {ObjectId,ObjectRef,dash,daisy,secure,signature} = require 'bongo'
  {Relationship}  = require 'jraphical'
  Validators = require '../../group/validators'
  {permit} = require '../../group/permissionset'

  @trait __dirname, '../../../traits/likeable'
  @trait __dirname, '../../../traits/notifying'
  @trait __dirname, '../../../traits/grouprelated'
  @trait __dirname, '../../../traits/protected'

  @share()

