       cloneData.config           ?= {}
       cloneData.config.clonedFrom = @getId()
 
-      # TODO make sure to clone custom credentials as well ~ GG
-
-      JStackTemplate.create client, cloneData, (err, cloneStackTemplate) ->
-        if err then callback new KodingError 'Clone failed', err
-        else callback null, cloneStackTemplate
+      { custom } = cloneData.credentials or {}
+      custom    ?= []
+
+      if custom.length > 0
+        cloneCustomCredentials client, custom, (err, creds) ->
+          return callback new KodingError 'Failed to clone credentials'  if err
+          cloneData.credentials.custom = creds
+          JStackTemplate.create client, cloneData, callback
+      else
+        JStackTemplate.create client, cloneData, callback
 
 
 # Base StackTemplate example for koding group

      @update { $set: data }, (err) => callback err, this


  clone: permit

    advanced: [

{ ObjectId, signature, daisy }  = require 'bongo'
{ Module, Relationship }        = require 'jraphical'
KodingError                     = require '../../error'


module.exports = class JStackTemplate extends Module
