       then { message: "Errors were encountered during validation", errors }
       else null
     )
-    
+
   @changePasswordByUsername = (username, password, callback) ->
     salt = createSalt()
     hashedPassword = hashPassword password, salt
     @update { username }, {
       $set: { salt, password: hashedPassword }
     }, callback
-  
+
   @changeEmailByUsername = (username, email, callback) ->
     @update { username }, { $set: { email }}, callback
-  
+
   @changeUsernameByAccount = (account, username, clientId, callback)->
     account.changeUsername username, (err) =>
       return callback err  if err?

  @addToGroup = (account, slug, email, invite, callback)->
    JGroup.one {slug}, (err, group)->
      if err or not group then callback err
      else if invite?.group isnt slug and group.privacy is 'private' and group.slug isnt 'koding'
        group.requestAccessFor account, callback
      else
        group.approveMember account, (err)->

      counterName : 'guest'
      offset      : 0
    }).next (err, guestId) =>
      return callback err  if err?

      username = "guest-#{guestId}"

