           next()
 
       (next) ->
-        JUser.persistOauthInfo username, client.sessionToken, next
+        JForeignAuth = require '../foreignauth'
+        JForeignAuth.persistOauthInfo {
+          sessionToken: client.sessionToken
+          group: client.context.group
+          username
+        }, next
 
       (next) ->
         return next()  unless username?


        if session.foreignAuth

        userUpdateOptions =
          $set        : userUpdateData
          $unset      :
            inactive  : 1



  ###*
   * Verify if `response` from client is valid by asking recaptcha servers.
   *
   * @param {string}   response
   * @param {function} callback
  ###
  @verifyRecaptcha = (response, params, callback) ->

    { url, secret } = KONFIG.recaptcha
    { slug }        = params

    # TODO: temporarily disable recaptcha for groups
    if slug? and slug isnt 'koding'
