   getHash =(value)->
     require('crypto').createHash('md5').update(value.toLowerCase()).digest('hex')
 
-  @whoami = secure ({connection:{delegate}}, callback)-> callback delegate
+  @whoami = secure ({connection:{delegate}}, callback)-> callback null, delegate
 
   checkBlockedStatus = (user, callback)->
     if user.status is 'blocked'

          if err or !invite?
            callback createKodingError 'Invalid invitation ID!'
          else
            callback null, yes, invite
      else
        callback null, yes

  @addToGroup = (account, slug, email, invite, callback)->
    JGroup.one {slug}, (err, group)->

        account.unstoreAll callback

  @persistOauthInfo: (username, clientId, callback)->
    @extractOauthFromSession clientId, (err, foreignAuthInfo)=>
      return callback err   if err
      return callback null  unless foreignAuthInfo
      return callback null  unless foreignAuthInfo.session

      @saveOauthToUser foreignAuthInfo, username, (err)=>
        return callback err  if err
        @clearOauthFromSession foreignAuthInfo.session, (err)=>
          return callback err  if err
          @copyPublicOauthToAccount username, foreignAuthInfo, callback

  @extractOauthFromSession: (clientId, callback)->
    JSession.one {clientId: clientId}, (err, session)->
      return callback err   if err
      return callback null  unless session

      {foreignAuth, foreignAuthType} = session
      if foreignAuth and foreignAuthType
        callback null, {foreignAuth, foreignAuthType, session}
      else
        callback null # WARNING: don't assume it's an error if there's no foreignAuth

  @saveOauthToUser: ({foreignAuth, foreignAuthType}, username, callback)->
    query = {}
