Skip to content
Snippets Groups Projects
Commit cf49c76e authored by dg's avatar dg
Browse files

new profile stuff working

git-svn-id: http://svn.net-core.org/repos/t-engine4@2766 51575b47-30f0-44d4-a5cc-537603b46e54
parent 7dfadbfa
No related branches found
No related tags found
No related merge requests found
......@@ -199,13 +199,15 @@ function _M:checkFirstRun()
return result
end
function _M:performlogin(login, pass, name, email)
function _M:performlogin(login, pass)
self.login=login
self.pass=pass
print("[ONLINE PROFILE] attempting log in ", self.login)
self.auth_tried = nil
self:tryAuth()
self:waitFirstAuth()
if (profile.auth) then
self.generic.online = { login=login, pass=pass,name=name or "", email=email or "" }
self.generic.online = { login=login, pass=pass }
self:saveGenericProfile("online", self.generic.online)
self:getConfigs("generic")
self:syncOnline("generic")
......@@ -372,7 +374,6 @@ function _M:syncOnline(module)
end
function _M:checkModuleHash(module, md5)
do self.hash_valid = true return true end
self.hash_valid = false
-- if not self.auth then return nil, "no online profile active" end
if config.settings.cheat then return nil, "cheat mode active" end
......@@ -422,9 +423,9 @@ function _M:newProfile(Login, Name, Password, Email)
core.profile.pushOrder(table.serialize{o="NewProfile2", login=Login, email=Email, name=Name, pass=Password})
local id = nil
self:waitEvent("NewProfile2", function(e) id = e.id end)
self:waitEvent("NewProfile2", function(e) id = e.uid end)
if not id then print("[ONLINE PROFILE] could not create") return end
print("[ONLINE PROFILE] profile id ", id)
self:performlogin(Login, Password, Name, Email)
self:performlogin(Login, Password)
end
......@@ -324,20 +324,25 @@ function _M:checkFirstTime()
end
function _M:createProfile(loginItem)
if self.justlogin then
if loginItem.justlogin then
self.auth_tried = nil
profile:performlogin(loginItem.login, loginItem.pass)
profile:waitFirstAuth()
if profile.auth then
Dialog:simplePopup("Profile logged in!", "Your online profile is active now...", function() end )
else
Dialog:simplePopup("Log in rejected", "Couldn't log you...", function() end )
Dialog:simplePopup("Login failed!", "Check your login and password or try again in in a few moments.", function() end )
end
return
end
profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email)
if (profile.auth) then
Dialog:simplePopup(self.justlogin and "Logged in!" or "Profile created!", "Your online profile is active now...", function() end )
else
Dialog:simplePopup("Profile failed to authenticate!", "Try logging in in a few moments", function() end )
self.auth_tried = nil
profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email)
profile:waitFirstAuth()
if profile.auth then
Dialog:simplePopup(self.justlogin and "Logged in!" or "Profile created!", "Your online profile is active now...", function() end )
else
Dialog:simplePopup("Profile creation failed!", "Try again in in a few moments, or try online at http://te4.org/", function() end )
end
end
end
......
......@@ -104,7 +104,7 @@ function _M:okclick()
end
game:unregisterDialog(self)
game:createProfile({login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text})
game:createProfile({justlogin=self.c_email and false or true, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text})
end
function _M:cancelclick()
......
......@@ -120,6 +120,15 @@ end
-- Orders comming from the main thread
--------------------------------------------------------------------
function _M:orderNewProfile2(o)
self:command("NEWP", table.serialize(o))
if self:read("200") then
cprofile.pushEvent(string.format("e='NewProfile2' uid=%d", tonumber(self.last_line) or -1))
else
cprofile.pushEvent("e='NewProfile2' uid=nil")
end
end
function _M:orderLogin(o)
-- Already logged?
if self.auth and self.auth.login == o.l then
......
......@@ -81,7 +81,7 @@ int push_event(lua_State *L)
{
size_t len;
const char *code = luaL_checklstring(L, 1, &len);
// printf("[profile event] %s\n", code);
printf("[profile event] %s\n", code);
profile_queue *q = malloc(sizeof(profile_queue));
char *d = calloc(len, sizeof(char));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment