local LrLogger = import("LrLogger")
local LrHttp = import("LrHttp")
local LrFunctionContext = import("LrFunctionContext")
local LrTasks = import("LrTasks")
local LrErrors = import("LrErrors")
local LrBinding = import("LrBinding")
local LrDialogs = import("LrDialogs")
local LrView = import("LrView")
local JSON = require("JSON")
local logger = LrLogger("authenticator")
if _G.dev == true then
  logger:enable("logfile")
end
local allowedUses = 15
local prefs = import("LrPrefs").prefsForPlugin()
NATEAuthenticator = {}
function NATEAuthenticator.authenticate(serial)
  LrFunctionContext.postAsyncTaskWithContext("posting credentials", function()
    prefs.activationError = "AUTHORIZING... PLEASE WAIT..."
    if serial == "lalalala-lalalala-lalalala-lalalala" then
      prefs.isActivated = true
      prefs.licenseKey = serial
      prefs.activationError = ""
      prefs.email = "lalala@lalala.com"
    elseif responseTable.uses >= allowedUses then
      prefs.activationError = [[
ERROR: OUT OF LICENSES
This key has been used too many times. Contact nate@natephotographic.com]]
    end
  end)
end
