       else if r.kodingUser
         callback createKodingError 'That username is taken!'
       else
-        @verifyEnrollmentEligibility {email, inviteCode}, (err, isEligible, invite)=>
+        @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

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

            else if not username? or not email?
              return callback createKodingError 'Username and email are required fields'

            @verifyKodingenPassword {username, password, kodingenUser}, (err) =>
              if err
                return callback createKodingError 'Wrong password'
              else
                JSession.one {clientId: client.sessionToken}, (err, session) =>
                  if err
                    callback err
                  else unless session
                    callback createKodingError 'Could not restore your session!'
                  else
                    userData = {
                      username, password, email, firstName, lastName
                    }
                    @createUser userData, (err, user, account) =>
                      return callback err  if err
                      @addToGroups account, invite, entryPoint, (err) ->
                        if err then callback err
                        else if silence
                          JUser.grantInitialInvitations user.username
                          createNewMemberActivity account
                          callback null, account
                        else
                          replacementToken = createId()
                          session.update {
                            $set:
                              username      : user.username
                              lastLoginDate : new Date
                              clientId      : replacementToken
                            $unset          :
                              guestId       : 1
                          }, (err, docs) ->
                            if err then callback err
                            else
                              user.sendEmailConfirmation()
                              JUser.grantInitialInvitations user.username
                              JUser.emit 'UserCreated', user
                              createNewMemberActivity account
                              JAccount.emit "AccountAuthenticated", account
                              callback null, account, replacementToken


  @grantInitialInvitations = (username)->
    JInvitation.grant {'profile.nickname': username}, 3, (err)->
