   addApiToken
   disableApiTokens
   fetchCurrentStateOfApiAccess
+  fetchOtaToken
 }

kookies = require 'kookies'
Tracker = require 'app/util/tracker'
VerifyPasswordModal = require 'app/commonviews/verifypasswordmodal'


loadTeam = ->


  team = groupsController.getCurrentGroup()
  state = team.isApiEnabled is yes
  reactor.dispatch actions.SET_API_ACCESS_STATE, { state }

fetchOtaToken = ->

  { reactor } = kd.singletons
  whoami().fetchOtaToken (err, token) ->

    cmd = if err
      "<a href='#'>Failed to generate your command, click to try again!</a>"
    else
      if globals.config.environment in ['dev', 'default', 'sandbox']
        "export KONTROLURL=#{KodingKontrol.getKontrolUrl()}; curl -sL https://sandbox.kodi.ng/c/d/kd | bash -s #{token}"
      else "curl -sL https://kodi.ng/c/p/kd | bash -s #{token}"

    reactor.dispatch actions.FETCH_OTA_TOKEN_SUCCESS, { cmd }



module.exports = {
