     # means no welcome e-mail for new users.
     # We're using it for migrating Kodingen users to Koding
     silence  = no
-    if client.connection.delegate?.can? 'migrate-kodingen-users'
+    if client.connection?.delegate?.can? 'migrate-kodingen-users'
       {silence} = userFormData
 
     @usernameAvailable username, (err, r)=>

      else if r.kodingUser
        callback createKodingError 'That username is taken!'
      else
        @verifyEnrollmentEligibility {email, inviteCode}, (err, isEligible, invite)=>
          if err
            callback createKodingError err.message
          else

        @addToGroup account, invite.group or entryPoint, invite.group?, callback
      else callback null

  @createUser = ({ username, email, password, firstName, lastName }, callback)->
    slug =
      slug            : username
      constructorName : 'JUser'
      usedAsPath      : 'username'
      collectionName  : 'jUsers'

    JName.claim username, [slug], 'JUser', (err)=>
      if err then callback err
      else
        salt = createSalt()
        user = new JUser {
          username
          email
          salt
          password: hashPassword(password, salt)
          emailFrequency: {
            global         : on
            daily          : on
            privateMessage : on
            followActions  : off
            comment        : on
            likeActivities : off
            groupInvite    : on
            groupRequest   : on
            groupApproved  : on
          }
        }
        user.save (err)=>
          if err
            if err.code is 11000
              callback createKodingError "Sorry, \"#{email}\" is already in use!"
            else callback err
          else
            hash = getHash email
            account = new JAccount
              profile: {
                nickname: username
                firstName
                lastName
                hash
              }
            account.save (err)=>
              if err then callback err
              else user.addOwnAccount account, (err) ->
                return callback err  if err
                callback null, user, account

  @register = secure (client, userFormData, callback)->
    {connection} = client
    {username, email, password, passwordConfirm, firstName, lastName,
