 learnLogout = ->
   win = new BrowserWindow(show: false)
   win.webContents.on 'did-finish-load', -> win.destroy()
-  win.loadURL("#{config.learnCo}/sign_out")
+  win.loadURL("#{learnCo}/sign_out")
 
 window.logout = ->
   _token.unset()

url = require 'url'
https = require 'https'
remote = require 'remote'
shell = require 'shell'
path = require 'path'
_token = require './token'
config = require './config'
BrowserWindow = remote.BrowserWindow

workspaceView = atom.views.getView(atom.workspace)

confirmOauthToken = (token) ->
  return new Promise (resolve, reject) ->
    try
      authRequest = https.get
        host: 'learn.co'
        path: '/api/v1/users/me?ile_version=' + atom.appVersion
        headers:
          'Authorization': 'Bearer ' + token
      , (response) ->
        body = ''

        response.on 'data', (d) ->
          body += d

        response.on 'error', reject

        response.on 'end', ->
          try
            parsed = JSON.parse(body)

            if parsed.email
              resolve parsed
            else
              resolve false
          catch
            reject false

      authRequest.on 'error', (err) ->
        reject err

    catch err
      reject err

githubLogin = () ->
  new Promise (resolve, reject) ->

        win.destroy()
        githubLogin().then(resolve)

    if not win.loadURL("#{learnCo}/ide/sign_in?ide_onboard=true")
      win.destroy()
      githubLogin.then(resolve)

githubLogout = ->
  win = new BrowserWindow(show: false)
