           returnUrl
         }
 
-      @fetchUserByProvider provider, session, (err, user) =>
+      { nickname: requester } = client.connection.delegate.profile
+
+      JForeignAuth = require '../foreignauth'
+      JForeignAuth.fetchFromSession session, provider, (err, foreignData) =>
 
         return callback new KodingError err.message  if err
 
         if isUserLoggedIn
-          if user and user.username isnt client.connection.delegate.profile.nickname
+
+          if foreignData and foreignData.username isnt requester
             JSession.clearOauthInfo session, ->
               callback new KodingError '''
                 Account is already linked with another user.


  ###*
   * Verify if `response` from client is valid by asking recaptcha servers.
   * Check is disabled in dev mode or when user is authenticating via `github`.
   *
   * @param {string}   response
   * @param {string}   foreignAuthType
   * @param {function} callback
  ###
  @verifyRecaptcha = (response, params, callback) ->

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

    return callback null  if foreignAuthType is 'github'

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


        if session.foreignAuth

          JForeignAuth = require '../foreignauth'
          JForeignAuth.persistOauthInfo {
            sessionToken: replacementToken
            group: session.group
            username
          }, (err) ->

            return next err  if err

            # TRACKER ----------------------------------------------- >> --
            providers = {}
            Object.keys(foreignAuth).forEach (provider) ->
              providers[provider] = yes

            Tracker.identify user.username, { foreignAuth: providers }
            # TRACKER ----------------------------------------------- << --

            next null

        else
          next()

      (next) ->

        # updating user data after login
        userUpdateOptions =
          $set        : { lastLoginDate : new Date }
          $unset      :
            inactive  : 1

