|
|
@ -81,7 +81,7 @@ extern bool SetMousePosFirstTime;
|
|
|
|
|
|
|
|
|
|
|
|
vector<CShard> Shards;
|
|
|
|
vector<CShard> Shards;
|
|
|
|
|
|
|
|
|
|
|
|
string LoginLogin, LoginPassword, ClientApp, Salt;
|
|
|
|
string LoginLogin, LoginPassword, ClientApp, Salt, LoginCustomParameters;
|
|
|
|
uint32 LoginShardId = 0xFFFFFFFF;
|
|
|
|
uint32 LoginShardId = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -847,6 +847,55 @@ void initAutoLogin()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void initAltLogin()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Check the alt param
|
|
|
|
|
|
|
|
if (!LoginCustomParameters.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// don't use login and password for alternate login
|
|
|
|
|
|
|
|
string res = checkLogin("", "", ClientApp, LoginCustomParameters);
|
|
|
|
|
|
|
|
if (res.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ClientCfg.R2Mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LoginSM.pushEvent(CLoginStateMachine::ev_login_ok);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Select good shard
|
|
|
|
|
|
|
|
ShardSelected = -1;
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < Shards.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Shards[i].ShardId == LoginShardId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ShardSelected = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ShardSelected == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
|
|
|
pIM->messageBoxWithHelp(CI18N::get("uiErrServerLost"), "ui:login");
|
|
|
|
|
|
|
|
LoginSM.pushEvent(CLoginStateMachine::ev_quit);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LoginSM.pushEvent(CLoginStateMachine::ev_login_ok);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// close the socket in case of error
|
|
|
|
|
|
|
|
HttpClient.disconnect();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ignore error
|
|
|
|
|
|
|
|
LoginSM.pushEvent(CLoginStateMachine::ev_login_not_alt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
// Called from client.cpp
|
|
|
|
// Called from client.cpp
|
|
|
@ -1174,7 +1223,7 @@ void onlogin(bool vanishScreen = true)
|
|
|
|
// Check the login/pass
|
|
|
|
// Check the login/pass
|
|
|
|
|
|
|
|
|
|
|
|
// main menu page for r2mode
|
|
|
|
// main menu page for r2mode
|
|
|
|
string res = checkLogin(LoginLogin, LoginPassword, ClientApp);
|
|
|
|
string res = checkLogin(LoginLogin, LoginPassword, ClientApp, LoginCustomParameters);
|
|
|
|
if (res.empty())
|
|
|
|
if (res.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if not in auto login, push login ok event
|
|
|
|
// if not in auto login, push login ok event
|
|
|
@ -1901,16 +1950,33 @@ class CAHOpenURL : public IActionHandler
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// modify existing languages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// old site
|
|
|
|
string::size_type pos_lang = url.find("/en/");
|
|
|
|
string::size_type pos_lang = url.find("/en/");
|
|
|
|
|
|
|
|
|
|
|
|
if(pos_lang!=string::npos)
|
|
|
|
// or new forums
|
|
|
|
url.replace(pos_lang+1, 2, ClientCfg.getHtmlLanguageCode());
|
|
|
|
if (pos_lang == string::npos)
|
|
|
|
|
|
|
|
pos_lang = url.find("=en#");
|
|
|
|
|
|
|
|
|
|
|
|
if(url.find('?')!=string::npos)
|
|
|
|
if (pos_lang != string::npos)
|
|
|
|
url += "&";
|
|
|
|
{
|
|
|
|
|
|
|
|
url.replace(pos_lang + 1, 2, ClientCfg.getHtmlLanguageCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
url += "?";
|
|
|
|
{
|
|
|
|
url += "language=" + ClientCfg.LanguageCode;
|
|
|
|
// append language
|
|
|
|
|
|
|
|
if (url.find('?') != string::npos)
|
|
|
|
|
|
|
|
url += "&";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
url += "?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url += "language=" + ClientCfg.LanguageCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!LoginCustomParameters.empty())
|
|
|
|
|
|
|
|
url += LoginCustomParameters;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openURL(url);
|
|
|
|
openURL(url);
|
|
|
|
|
|
|
|
|
|
|
|
nlinfo("openURL %s", url.c_str());
|
|
|
|
nlinfo("openURL %s", url.c_str());
|
|
|
@ -2333,6 +2399,10 @@ bool initCreateAccount()
|
|
|
|
CurlHttpClient.verifyServer(true); // set this to false if you need to connect to the test environment
|
|
|
|
CurlHttpClient.verifyServer(true); // set this to false if you need to connect to the test environment
|
|
|
|
|
|
|
|
|
|
|
|
std::string params = "language=" + lang;
|
|
|
|
std::string params = "language=" + lang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!LoginCustomParameters.empty())
|
|
|
|
|
|
|
|
params += LoginCustomParameters;
|
|
|
|
|
|
|
|
|
|
|
|
if(!CurlHttpClient.sendGet(url, params, pPM->isVerboseLog()))
|
|
|
|
if(!CurlHttpClient.sendGet(url, params, pPM->isVerboseLog()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring errorMessage("Can't send (error code 60)");
|
|
|
|
ucstring errorMessage("Can't send (error code 60)");
|
|
|
@ -2523,6 +2593,9 @@ class CAHOnCreateAccountSubmit : public IActionHandler
|
|
|
|
if(conditionsPushed)
|
|
|
|
if(conditionsPushed)
|
|
|
|
params += "&TaC=1";
|
|
|
|
params += "&TaC=1";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!LoginCustomParameters.empty())
|
|
|
|
|
|
|
|
params += LoginCustomParameters;
|
|
|
|
|
|
|
|
|
|
|
|
std::string md5 = results[0] + results[1] + "" + results[3];
|
|
|
|
std::string md5 = results[0] + results[1] + "" + results[3];
|
|
|
|
md5 = NLMISC::getMD5((uint8*)md5.data(), (uint32)md5.size()).toString();
|
|
|
|
md5 = NLMISC::getMD5((uint8*)md5.data(), (uint32)md5.size()).toString();
|
|
|
|
|
|
|
|
|
|
|
@ -2707,7 +2780,7 @@ REGISTER_ACTION_HANDLER (CAHOnBackToLogin, "on_back_to_login");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
string checkLogin(const string &login, const string &password, const string &clientApp)
|
|
|
|
string checkLogin(const string &login, const string &password, const string &clientApp, const std::string &customParameters)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CPatchManager *pPM = CPatchManager::getInstance();
|
|
|
|
CPatchManager *pPM = CPatchManager::getInstance();
|
|
|
|
Shards.clear();
|
|
|
|
Shards.clear();
|
|
|
@ -2725,50 +2798,64 @@ string checkLogin(const string &login, const string &password, const string &cli
|
|
|
|
|
|
|
|
|
|
|
|
std::string url = ClientCfg.ConfigFile.getVar("StartupHost").asString() + ClientCfg.ConfigFile.getVar("StartupPage").asString();
|
|
|
|
std::string url = ClientCfg.ConfigFile.getVar("StartupHost").asString() + ClientCfg.ConfigFile.getVar("StartupPage").asString();
|
|
|
|
|
|
|
|
|
|
|
|
// ask server for salt
|
|
|
|
// don't use login with alt method
|
|
|
|
if(!HttpClient.sendGet(url + "?cmd=ask&cp=2&login=" + login + "&lg=" + ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
|
|
|
if (!login.empty())
|
|
|
|
return "Can't send (error code 60)";
|
|
|
|
{
|
|
|
|
|
|
|
|
// ask server for salt
|
|
|
|
|
|
|
|
if(!HttpClient.sendGet(url + "?cmd=ask&cp=2&login=" + login + "&lg=" + ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
|
|
|
|
|
|
|
|
return "Can't send (error code 60)";
|
|
|
|
|
|
|
|
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Sent request for password salt");
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Sent request for password salt");
|
|
|
|
|
|
|
|
|
|
|
|
if(!HttpClient.receive(res, pPM->isVerboseLog()))
|
|
|
|
if(!HttpClient.receive(res, pPM->isVerboseLog()))
|
|
|
|
return "Can't receive (error code 61)";
|
|
|
|
return "Can't receive (error code 61)";
|
|
|
|
|
|
|
|
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Received request login check");
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Received request login check");
|
|
|
|
|
|
|
|
|
|
|
|
if(res.empty())
|
|
|
|
if(res.empty())
|
|
|
|
return "Empty answer from server (error code 62)";
|
|
|
|
return "Empty answer from server (error code 62)";
|
|
|
|
|
|
|
|
|
|
|
|
if(res[0] == '0')
|
|
|
|
if(res[0] == '0')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// server returns an error
|
|
|
|
// server returns an error
|
|
|
|
nlwarning("server error: %s", res.substr(2).c_str());
|
|
|
|
nlwarning("server error: %s", res.substr(2).c_str());
|
|
|
|
return res.substr(2);
|
|
|
|
return res.substr(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(res[0] == '1')
|
|
|
|
else if(res[0] == '1')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Salt = res.substr(2);
|
|
|
|
Salt = res.substr(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// server returns ???
|
|
|
|
// server returns ???
|
|
|
|
nlwarning("%s", res.c_str());
|
|
|
|
nlwarning("%s", res.c_str());
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// send login + crypted password + client app and cp=2 (as crypted password)
|
|
|
|
// send login + crypted password + client app and cp=2 (as crypted password)
|
|
|
|
if(!HttpClient.connectToLogin())
|
|
|
|
if(!HttpClient.connectToLogin())
|
|
|
|
return "Can't connect (error code 63)";
|
|
|
|
return "Can't connect (error code 63)";
|
|
|
|
|
|
|
|
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Connected");
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Connected");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ClientCfg.R2Mode)
|
|
|
|
if (ClientCfg.R2Mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// R2 login sequence
|
|
|
|
// R2 login sequence
|
|
|
|
std::string cryptedPassword = CCrypt::crypt(password, Salt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!HttpClient.sendGet(url + "?cmd=login&login=" + login + "&password=" + cryptedPassword + "&clientApplication=" + clientApp + "&cp=2" + "&lg=" + ClientCfg.LanguageCode))
|
|
|
|
if (!login.empty())
|
|
|
|
return "Can't send (error code 2)";
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string cryptedPassword = CCrypt::crypt(password, Salt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!HttpClient.sendGet(url + "?cmd=login&login=" + login + "&password=" + cryptedPassword + "&clientApplication=" + clientApp + "&cp=2" + "&lg=" + ClientCfg.LanguageCode + customParameters))
|
|
|
|
|
|
|
|
return "Can't send (error code 2)";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// don't send login and password if empty
|
|
|
|
|
|
|
|
if(!HttpClient.sendGet(url + "?cmd=login&clientApplication=" + clientApp + "&cp=2" + "&lg=" + ClientCfg.LanguageCode + customParameters))
|
|
|
|
|
|
|
|
return "Can't send (error code 2)";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// the response should contains the result code and the cookie value
|
|
|
|
// the response should contains the result code and the cookie value
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Sent request login check");
|
|
|
|
if(pPM->isVerboseLog()) nlinfo("Sent request login check");
|
|
|
|