Add authUser

This commit is contained in:
insweater 2015-02-05 17:39:36 +03:00
parent b4bacc65d9
commit c1c456e0f8

View File

@ -1,5 +1,5 @@
local md5 = require "md5"
local http = require "http"
local http = require "socket.http"
local GJ = {
gameID, gameKey,
@ -7,10 +7,10 @@ local GJ = {
username, userToken
}
local BASE_URL = "http://gamejolt.com/api/game/v1"
local BASE_URL = "http://gamejolt.com/api/game/v1/"
local function req(s, pu, pt, f)
local url = s .. "&game_id=" .. tostring(GJ.gameID) .. "&format=" .. f
local function req(s, f, pu, pt)
local url = BASE_URL .. s .. "&game_id=" .. tostring(GJ.gameID) .. "&format=" .. f
if pu then url = url .. "&username=" .. GJ.username end
if pt then url = url .. "&user_token=" .. GJ.userToken end
@ -26,4 +26,14 @@ function GJ.init(id, key)
GJ.gameKey = key
end
-- users
function GJ.authUser(name, token)
GJ.username = name
GJ.userToken = token
local s = string.find(req("users/auth/?", "dump", true, true), "SUCCESS") ~= nil
GJ.isLoggedIn = s
return s
end
return GJ