Fix almost everything #8

Closed
pablomayobre wants to merge 11 commits from master into master
Showing only changes of commit 35d7146627 - Show all commits

View File

@ -54,15 +54,29 @@ local function handleTrophies(str)
return t return t
end end
function GJ.init(id, key) function GJ.init(id, key, args)
GJ.gameID = id GJ.gameID = id
GJ.gameKey = key GJ.gameKey = key
if args and type(args)=="table" then
for k,v in pairs(args) do
local a = v:match("^gjapi_(.*)")
if a then
key, value = a:match("^(.-)=(.-)$")
if key == "username" then
GJ.username = value
elseif key == "token" then
GJ.userToken = value
end
end
end
end
end end
-- users -- users
function GJ.authUser(name, token) function GJ.authUser(name, token)
GJ.username = name GJ.username = name or GJ.username
GJ.userToken = token GJ.userToken = token or GJ.userToken
local s = string.find(req("users/auth/?", "dump", true, true), "SUCCESS") ~= nil local s = string.find(req("users/auth/?", "dump", true, true), "SUCCESS") ~= nil
GJ.isLoggedIn = s GJ.isLoggedIn = s