 
     success: (client, options, callback) ->
 
-      { title, config } = options
-
-      unless title or config
+      { title, config, credentials } = options
+
+      unless title or config or credentials
         return callback new KodingError 'Nothing to update'
 
-      title  ?= @title
-      config ?= @config
-
-      @update $set : { title, config }, (err) ->
+      dataToUpdate        = {}
+      dataToUpdate.title  = title   if title?
+      dataToUpdate.config = config  if config?
+
+      if credentials?
+        unless typeof credentials is 'object'
+          return callback new KodingError 'Credential should be an Object'
+
+        sanitized = {}
+        for key, value of credentials
+          if key in SUPPORTED_CREDS
+            sanitized[key] = uniq value
+
+        dataToUpdate.credentials = sanitized
+
+      @update $set : dataToUpdate, (err) ->
         return callback err  if err?
         callback null
 


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

  @trait __dirname, '../traits/protected'


        @remove callback


  SUPPORTED_CREDS = (Object.keys PROVIDERS).concat ['userInput', 'custom']

  modify: permit

