 
 getPrivateToken = (options, callback) ->
 
-  { urlData: { baseUrl }, token } = options
+  { urlData: { baseUrl }, token, juser } = options
 
   params    =
     url     : "#{baseUrl}/api/v3/user"

    { url, privateToken } = importParams
    return  unless urlData = @parseImportUrl url

    if privateToken
      @importStackTemplateWithPrivateToken privateToken, urlData, callback
    else if oauth = user.getAt 'foreignAuth.gitlab'
      @importStackTemplateWithOauth oauth, urlData, callback
    else
      @importStackTemplateWithRawUrl urlData, callback


      console.log '[GITLAB] TOKEN NOT FOUND ON DATA:', data
      return callback new KodingError 'Auth failed'

    juser.update {
      $set: {
        'foreignAuth.gitlab.privateToken': token
      }
    }, (err) ->

      console.warn 'Error while updating private token:', err  if err

      # Swallow update error here thus we don't need it ~GG
      callback null, token


module.exports = GitLabProvider =
